Merge branch 'master' of https://github.com/nojhan/dotfiles
This commit is contained in:
commit
e26dc9a2b5
12 changed files with 190 additions and 12 deletions
30
.bashrc
30
.bashrc
|
|
@ -167,12 +167,28 @@ function psg() {
|
|||
}
|
||||
|
||||
|
||||
# Notify when a command is completed, with an audio and visual warning.
|
||||
# Notify when a command is completed, with a visual warning.
|
||||
function notify() {
|
||||
cmd=$(echo "$1" | sed 's/&/&/g')
|
||||
if [[ "$1" != "" ]] ; then
|
||||
$@
|
||||
fi
|
||||
if [[ $? ]] ; then
|
||||
msg="Your \"$cmd\" command is completed"
|
||||
else
|
||||
msg="There was an error in your \"$cmd\" command"
|
||||
fi
|
||||
zenity --info --text "$msg\nin $((e-s)) s\n$(date)" &
|
||||
}
|
||||
|
||||
# Notify when a command is completed, with an audio and visual warning.
|
||||
function notice() {
|
||||
s=$SECONDS
|
||||
|
||||
cmd="$1"
|
||||
$@
|
||||
cmd=$(echo "$1" | sed 's/&/&/g')
|
||||
if [[ "$1" != "" ]] ; then
|
||||
$@
|
||||
fi
|
||||
if [[ $? ]] ; then
|
||||
msg="Your \"$cmd\" command is completed"
|
||||
else
|
||||
|
|
@ -183,11 +199,15 @@ function notify() {
|
|||
# if the command has run more than a minute
|
||||
# then say loudly that it ended
|
||||
e=$SECONDS
|
||||
if [[ $((e-s)) -ge 60 ]] ; then
|
||||
if [[ $((e-s)) -ge 1 ]] ; then
|
||||
espeak -s 110 "$msg" 2>/dev/null >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# Notify with a visual warning.
|
||||
function ended() {
|
||||
notify
|
||||
}
|
||||
|
||||
##########
|
||||
# Coding #
|
||||
|
|
@ -311,7 +331,7 @@ echo "rcp : copy with rsync/ssh"
|
|||
}
|
||||
|
||||
# do not permits to recall dangerous commands in bash history
|
||||
export HISTIGNORE='&:[bf]g:exit:*>|*:*rm*-rf*:*rm*-f*'
|
||||
export HISTIGNORE='&:[bf]g:exit:*>|*:*rm*-rf*'
|
||||
# append history rather than overwrite
|
||||
shopt -s histappend
|
||||
# one command per line
|
||||
|
|
|
|||
14
.gdbinit
14
.gdbinit
|
|
@ -84,9 +84,13 @@ end
|
|||
|
||||
|
||||
define hook-backtrace
|
||||
# match the [path]file[.ext]: (.*/)?(?:$|(.+?)(?:(\.[^.]*)|))
|
||||
# shell cat /tmp/coloutPipe | colout "^(#)([0-9]+)\s+(0x\S+ )*(in )*([^()]+[()]*) (\(.*\)) at (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)):([0-9]+)" red,red,blue,none,green,cpp,none,white,white,yellow normal,bold,normal,normal,normal,normal,normal,bold,bold,bold &
|
||||
shell cat /tmp/coloutPipe | colout "^(#)([0-9]+)\s+(0x\S+ )*(in )*(.*) (\(.*\)) (at) (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)):([0-9]+)" red,red,blue,red,green,magenta,red,none,white,white,yellow normal,bold,normal,normal,normal,normal,normal,bold,bold,bold | colout "([\w\s]*?)(=)([^,]*?)([,\)])" yellow,blue,magenta,blue normal &
|
||||
# Note: match path = [path]file[.ext] = (.*/)?(?:$|(.+?)(?:(\.[^.]*)|))
|
||||
# This line color highlights:
|
||||
# – lines that link to source code,
|
||||
# – function call in green,
|
||||
# – arguments names in yellow, values in magenta,
|
||||
# — the parent directory in bold red (assuming that the debug session would be in a "project/build/" directory).
|
||||
shell cat /tmp/coloutPipe | colout "^(#)([0-9]+)\s+(0x\S+ )*(in )*(.*) (\(.*\)) (at) (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)):([0-9]+)" red,red,blue,red,green,magenta,red,none,white,white,yellow normal,bold,normal,normal,normal,normal,normal,bold,bold,bold | colout "([\w\s]*?)(=)([^,]*?)([,\)])" yellow,blue,magenta,blue normal | colout "/($(basename $(dirname $(pwd))))/" red bold &
|
||||
logging_on
|
||||
end
|
||||
define hookpost-backtrace
|
||||
|
|
@ -114,7 +118,7 @@ end
|
|||
|
||||
define hook-frame
|
||||
#shell cat /tmp/coloutPipe | colout "^(#)([0-9]+)\s+(0x\S+ )*(in )*(.*) (at) (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)):([0-9]+)" red,red,blue,red,green,red,magenta,none,white,white,yellow normal,bold,normal,normal,bold,normal,normal,bold,bold,bold | colout "^([0-9]+)\s+(.*)$" yellow,Cpp &
|
||||
shell cat /tmp/coloutPipe | colout "^(#)([0-9]+)\s+(0x\S+ )*(in )*(.*) (\(.*\)) (at) (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)):([0-9]+)" red,red,blue,red,green,magenta,red,none,white,white,yellow normal,bold,normal,normal,normal,normal,normal,bold,bold,bold | colout "^([0-9]+)\s*(.*)$" red,Cpp &
|
||||
shell cat /tmp/coloutPipe | colout "^(#)([0-9]+)\s+(0x\S+ )*(in )*(.*) (\(.*\)) (at) (.*/)?(?:$|(.+?)(?:(\.[^.]*)|)):([0-9]+)" red,red,blue,red,green,magenta,red,none,white,white,yellow normal,bold,normal,normal,normal,normal,normal,bold,bold,bold | colout "([\w\s]*?)(=)([^,]*?)([,\)])" yellow,blue,magenta,blue normal &
|
||||
logging_on
|
||||
end
|
||||
define hookpost-frame
|
||||
|
|
@ -128,7 +132,7 @@ define hook-quit
|
|||
end
|
||||
|
||||
define hook-display
|
||||
shell cat /tmp/coloutPipe | colout "^([0-9]+)(:) (.+?) (=) " red,blue,red,blue normal,normal,bold,normal | colout "(@)(0x\S+)(:)" red,blue,red normal &
|
||||
shell cat /tmp/coloutPipe | colout "^([0-9]+)(:) (.+?) (=) " red,blue,white,blue normal,normal,bold,normal | colout "(@)(0x\S+)(:)" red,blue,red normal &
|
||||
logging_on
|
||||
end
|
||||
define hookpost-display
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
co = checkout
|
||||
# create branch
|
||||
cb = checkout -b
|
||||
ci = commit -a -v
|
||||
ci = commit -v
|
||||
ca = commit -v -a
|
||||
br = branch
|
||||
sta = stash
|
||||
[pager]
|
||||
|
|
@ -19,3 +20,5 @@
|
|||
diff = less -R +'/^\\@\\@\\s'
|
||||
[color]
|
||||
ui = auto
|
||||
[push]
|
||||
default = simple
|
||||
|
|
|
|||
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -64,3 +64,6 @@
|
|||
[submodule ".vim/bundle/vim-snippets"]
|
||||
path = .vim/bundle/vim-snippets
|
||||
url = https://github.com/honza/vim-snippets.git
|
||||
[submodule ".vim/bundle/color_coded"]
|
||||
path = .vim/bundle/color_coded
|
||||
url = https://github.com/jeaye/color_coded.git
|
||||
|
|
|
|||
|
|
@ -36,9 +36,12 @@ defbindings("WMPlex.toplevel", {
|
|||
-- firefox
|
||||
kpress(META.."F4", "ioncore.exec_on(_, 'firefox')"),
|
||||
|
||||
-- firefox
|
||||
-- Nautilus
|
||||
kpress(META.."F5", "ioncore.exec_on(_, 'nautilus --no-desktop')"),
|
||||
|
||||
-- Lock
|
||||
kpress(META.."l", "ioncore.exec_on(_, 'gnome-screensaver-command -l')"),
|
||||
|
||||
-- menu général ion3
|
||||
kpress(META.."F12", "mod_query.query_menu(_, _sub, 'mainmenu', 'Main menu:')")
|
||||
})
|
||||
|
|
|
|||
1
.vim/bundle/color_coded
Submodule
1
.vim/bundle/color_coded
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 07eab1106fa1c26dd1936b7d031d843170eb9d8f
|
||||
7
rsnapshot_anacron/daily/rsnapshot_daily
Executable file
7
rsnapshot_anacron/daily/rsnapshot_daily
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
source <BASE>/rsnapshot_common
|
||||
|
||||
# 86400 seconds in a day, retry every 10 minutes for half a day
|
||||
backup "40000" "daily"
|
||||
|
||||
6
rsnapshot_anacron/hourly/rsnapshot_hourly
Executable file
6
rsnapshot_anacron/hourly/rsnapshot_hourly
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
source <BASE>/rsnapshot_common
|
||||
|
||||
# 3600 seconds in an hour, retry every 10 minutes for half an hour
|
||||
backup "1800" "hourly"
|
||||
67
rsnapshot_anacron/install.sh
Executable file
67
rsnapshot_anacron/install.sh
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Immediately exit if any command has a non-zero exit.
|
||||
# A reference to any variable you haven't previously defined - with the exceptions of $* and $@ - is an error.
|
||||
# If any command in a pipeline fails, that return code will be used as the return code of the whole pipeline.
|
||||
set -euo pipefail
|
||||
|
||||
user="$USER"
|
||||
|
||||
mkdir -p $HOME/scripts
|
||||
cp -r ../rsnapshot_anacron $HOME/scripts/
|
||||
cd $HOME/scripts/rsnapshot_anacron/
|
||||
|
||||
base="$(pwd)"
|
||||
|
||||
# Check installed packages
|
||||
installed="$(dpkg -l rsnapshot)|grep '^ii\srsnapshot\s'"
|
||||
if [[ "$installed" == "" ]]; then
|
||||
echo "rsnapshot is not installed"
|
||||
echo "You should install it and edit /etc/rsnapshot.conf:"
|
||||
echo "sudo apt install rsnapshot anacron && sudo gvim /etc/rsnapshot.conf"
|
||||
exit 100
|
||||
fi
|
||||
sudo apt install anacron
|
||||
|
||||
|
||||
snapshot=$(grep "^snapshot_root.*$" /etc/rsnapshot.conf|cut -f 2)
|
||||
|
||||
if [[ $? != 0 || "$snapshot" == "" ]] ; then
|
||||
echo "No snapshot_root in /etc/rsnapshot.conf"
|
||||
exit 101
|
||||
fi
|
||||
|
||||
tag="=^=rsnapshot_anacron=^="
|
||||
if [[ $(grep "$tag" /etc/anacrontab) == "" ]]; then
|
||||
echo "
|
||||
##########################################################
|
||||
# $tag
|
||||
# périodicité (jours),
|
||||
# | délai (minutes),
|
||||
# | | nom de la tache,
|
||||
# | | | commandes
|
||||
##########################################################
|
||||
@daily 10 backup.daily sudo -u $user run-parts $base/daily/
|
||||
@weekly 10 backup.weekly sudo -u $user run-parts $base/weekly/
|
||||
@monthly 10 backup.monthly sudo -u $user run-parts $base/monthly/
|
||||
" | sudo tee -a /etc/anacrontab
|
||||
fi
|
||||
|
||||
# Test if snapshot dir is set
|
||||
source $base/rsnapshot_common
|
||||
if [[ "$SNAPSHOT_ROOT" == "<NOT_DEFINED>" ]] ; then
|
||||
sed -i "s,<NOT_DEFINED>,${snapshot},g" rsnapshot_common
|
||||
else
|
||||
if [[ "$SNAPSHOT_ROOT" != "$snapshot" ]] ; then
|
||||
echo "snapshot_root in /etc/rsnapshot.conf is different than SNAPSHOT_ROOT in rsnapshot_common"
|
||||
exit 102
|
||||
fi
|
||||
fi
|
||||
|
||||
# Configure absolute path in scripts
|
||||
sed -i "s,<BASE>,$base,g" $base/hourly/rsnapshot_hourly
|
||||
sed -i "s,<BASE>,$base,g" $base/daily/rsnapshot_daily
|
||||
sed -i "s,<BASE>,$base,g" $base/weekly/rsnapshot_weekly
|
||||
sed -i "s,<BASE>,$base,g" $base/monthly/rsnapshot_monthly
|
||||
|
||||
echo "DONE"
|
||||
7
rsnapshot_anacron/monthly/rsnapshot_monthly
Executable file
7
rsnapshot_anacron/monthly/rsnapshot_monthly
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
source <BASE>/rsnapshot_common
|
||||
|
||||
# 2592000 seconds in a month, retry every 10 minutes for 8 days
|
||||
backup "691200" "monthly"
|
||||
|
||||
50
rsnapshot_anacron/rsnapshot_common
Normal file
50
rsnapshot_anacron/rsnapshot_common
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# Immediately exit if any command has a non-zero exit.
|
||||
# A reference to any variable you haven't previously defined - with the exceptions of $* and $@ - is an error.
|
||||
# If any command in a pipeline fails, that return code will be used as the return code of the whole pipeline.
|
||||
set -euo pipefail
|
||||
|
||||
# There are already cron scripts installed to automatically run rsnapshot in
|
||||
# the background on a regular hourly/daily/weekly/monthly schedule. If this
|
||||
# is on a machine that is shutdown or goes to sleep often, then install
|
||||
# anacron.
|
||||
#
|
||||
ENABLE_CRON=no
|
||||
|
||||
# Also run the hourly job in addition to the daily, weekly, and monthly
|
||||
#ENABLE_HOURLY=yes
|
||||
|
||||
# Specify the disk where the backups are written to, this is the same place as
|
||||
# is specified in /etc/rsnapshot.conf as 'snapshot_root'. This is used to
|
||||
# detect if the disk is mounted or not when rsnapshot runs in a cron job.
|
||||
#
|
||||
SNAPSHOT_ROOT="<NOT_DEFINED>"
|
||||
|
||||
RSNAPSHOT="/usr/bin/rsnapshot"
|
||||
|
||||
function backup()
|
||||
{
|
||||
wait="$1" # in seconds
|
||||
freq="$2" # hourly, daily, weekly or monthly
|
||||
|
||||
#retry every 10 minutes
|
||||
every=600
|
||||
|
||||
if [[ "$ENABLE_CRON" == "yes" ]] ; then
|
||||
exit 1000
|
||||
fi
|
||||
|
||||
until=$(( $(date +%s) + $wait))
|
||||
while [[ $(date +%s) < $until ]] ; do
|
||||
test -d "$SNAPSHOT_ROOT" && break
|
||||
sleep $every
|
||||
done
|
||||
|
||||
# See ionice(1)
|
||||
if [ -x /usr/bin/ionice ] &&
|
||||
/usr/bin/ionice -c3 true 2>/dev/null; then
|
||||
IONICE="/usr/bin/ionice -c3"
|
||||
fi
|
||||
|
||||
test -d "$SNAPSHOT_ROOT" && \
|
||||
nice -n 20 $IONICE $RSNAPSHOT $freq
|
||||
}
|
||||
7
rsnapshot_anacron/weekly/rsnapshot_weekly
Executable file
7
rsnapshot_anacron/weekly/rsnapshot_weekly
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
source <BASE>/rsnapshot_common
|
||||
|
||||
# 604800 seconds in a week, retry every 10 minutes for 4 days
|
||||
backup "345600" "weekly"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue