From 30685f6f7b71a115d4b40ca8ff9a5e2d16439699 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 2 Nov 2016 11:57:23 +0100 Subject: [PATCH 1/9] Add color_coded vim plugin --- .gitmodules | 3 +++ .vim/bundle/color_coded | 1 + 2 files changed, 4 insertions(+) create mode 160000 .vim/bundle/color_coded diff --git a/.gitmodules b/.gitmodules index 1eeae93..bde7dcd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/.vim/bundle/color_coded b/.vim/bundle/color_coded new file mode 160000 index 0000000..07eab11 --- /dev/null +++ b/.vim/bundle/color_coded @@ -0,0 +1 @@ +Subproject commit 07eab1106fa1c26dd1936b7d031d843170eb9d8f From e03d38089da1d66e998367f0a66471fb4610625d Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 2 Nov 2016 11:57:40 +0100 Subject: [PATCH 2/9] Better coloring scheme for gdb --- .gdbinit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gdbinit b/.gdbinit index c31240c..794ea2a 100644 --- a/.gdbinit +++ b/.gdbinit @@ -114,7 +114,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 +128,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 From 9694a319c2113cf14cb1de5c09d8168a3d09a7d3 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 2 Nov 2016 16:33:10 +0100 Subject: [PATCH 3/9] Add screen lock shortcut --- .notion/cfg_notion.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.notion/cfg_notion.lua b/.notion/cfg_notion.lua index fcc3c9e..819d151 100644 --- a/.notion/cfg_notion.lua +++ b/.notion/cfg_notion.lua @@ -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:')") }) From 92b725513834bcf59162d38ec83a9919218d4254 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 23 Nov 2016 09:12:35 +0100 Subject: [PATCH 4/9] Better notifications functions --- .bashrc | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/.bashrc b/.bashrc index 181bde0..c713573 100644 --- a/.bashrc +++ b/.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 # @@ -310,7 +330,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 From 9b85d0cc05e8d2576d1c21acf335255fc176665a Mon Sep 17 00:00:00 2001 From: nojhan Date: Thu, 2 Nov 2017 17:13:07 +0100 Subject: [PATCH 5/9] git ci and ca --- .gitconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitconfig b/.gitconfig index f6bcc1d..5ac9949 100644 --- a/.gitconfig +++ b/.gitconfig @@ -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] From 8a5d002e97a8000ae9d68dba6270e6145585ce40 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 20 Feb 2018 14:37:34 +0100 Subject: [PATCH 6/9] [gdb] color the parent directory in backtrace Assuming that the debug session would be in a "project/build/" directory, like for a classical CMake built project. --- .gdbinit | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.gdbinit b/.gdbinit index 794ea2a..b9774fe 100644 --- a/.gdbinit +++ b/.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 From b88f1f3566ed5ec621a00079ce823143cfb049e5 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sat, 3 Mar 2018 14:07:50 +0100 Subject: [PATCH 7/9] rsnapshot/anacron backup settings --- rsnapshot_anacron/daily/rsnapshot_daily | 7 +++ rsnapshot_anacron/hourly/rsnapshot_hourly | 6 ++ rsnapshot_anacron/install.sh | 69 +++++++++++++++++++++ rsnapshot_anacron/monthly/rsnapshot_monthly | 7 +++ rsnapshot_anacron/rsnapshot_common | 50 +++++++++++++++ rsnapshot_anacron/weekly/rsnapshot_weekly | 7 +++ 6 files changed, 146 insertions(+) create mode 100755 rsnapshot_anacron/daily/rsnapshot_daily create mode 100755 rsnapshot_anacron/hourly/rsnapshot_hourly create mode 100644 rsnapshot_anacron/install.sh create mode 100755 rsnapshot_anacron/monthly/rsnapshot_monthly create mode 100644 rsnapshot_anacron/rsnapshot_common create mode 100755 rsnapshot_anacron/weekly/rsnapshot_weekly diff --git a/rsnapshot_anacron/daily/rsnapshot_daily b/rsnapshot_anacron/daily/rsnapshot_daily new file mode 100755 index 0000000..991d210 --- /dev/null +++ b/rsnapshot_anacron/daily/rsnapshot_daily @@ -0,0 +1,7 @@ +#!/bin/bash + +source /rsnapshot_common + +# 86400 seconds in a day, retry every 10 minutes for half a day +backup "40000" "daily" + diff --git a/rsnapshot_anacron/hourly/rsnapshot_hourly b/rsnapshot_anacron/hourly/rsnapshot_hourly new file mode 100755 index 0000000..b791a84 --- /dev/null +++ b/rsnapshot_anacron/hourly/rsnapshot_hourly @@ -0,0 +1,6 @@ +#!/bin/bash + +source /rsnapshot_common + +# 3600 seconds in an hour, retry every 10 minutes for half an hour +backup "1800" "hourly" diff --git a/rsnapshot_anacron/install.sh b/rsnapshot_anacron/install.sh new file mode 100644 index 0000000..a544c33 --- /dev/null +++ b/rsnapshot_anacron/install.sh @@ -0,0 +1,69 @@ +#!/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 $user/scripts +cp -r ../anacron $user/scripts/ +cd $user/scripts/ + +base="$(pwd)" + +# Check installed packages +installed="$(dpkg -l rsnapshot)|grep '^ii\srsnapshot\s'" +if [[ "$sintalled" == "" ]]; 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 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 +sudo 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/ +" >> /etc/anacrontab +fi + +ln -s $base ~/.anacron + +# Test if snapshot dir is set +source $base/rsnapshot_common +if [[ "$SNAPSHOT_ROOT" == "" ]] ; then + sed -i "s,,${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,g" $base/hourly/rsnapshot_hourly +sed -i "s,,$base,g" $base/daily/rsnapshot_daily +sed -i "s,,$base,g" $base/weekly/rsnapshot_weekly +sed -i "s,,$base,g" $base/monthly/rsnapshot_monthly + +echo "DONE" diff --git a/rsnapshot_anacron/monthly/rsnapshot_monthly b/rsnapshot_anacron/monthly/rsnapshot_monthly new file mode 100755 index 0000000..01cbb5c --- /dev/null +++ b/rsnapshot_anacron/monthly/rsnapshot_monthly @@ -0,0 +1,7 @@ +#!/bin/bash + +source /rsnapshot_common + +# 2592000 seconds in a month, retry every 10 minutes for 8 days +backup "691200" "monthly" + diff --git a/rsnapshot_anacron/rsnapshot_common b/rsnapshot_anacron/rsnapshot_common new file mode 100644 index 0000000..e82ee9f --- /dev/null +++ b/rsnapshot_anacron/rsnapshot_common @@ -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="" + +RSNAPSHOT="/usr/bin/rsnapshot -t" + +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 +} diff --git a/rsnapshot_anacron/weekly/rsnapshot_weekly b/rsnapshot_anacron/weekly/rsnapshot_weekly new file mode 100755 index 0000000..171147e --- /dev/null +++ b/rsnapshot_anacron/weekly/rsnapshot_weekly @@ -0,0 +1,7 @@ +#!/bin/bash + +source /rsnapshot_common + +# 604800 seconds in a week, retry every 10 minutes for 4 days +backup "345600" "weekly" + From 0d00dd91da0278746fad0f612444799c406d510a Mon Sep 17 00:00:00 2001 From: nojhan Date: Sat, 3 Mar 2018 14:41:37 +0100 Subject: [PATCH 8/9] bugfixes rsnapshot/anacron --- rsnapshot_anacron/install.sh | 16 +++++++--------- rsnapshot_anacron/rsnapshot_common | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) mode change 100644 => 100755 rsnapshot_anacron/install.sh diff --git a/rsnapshot_anacron/install.sh b/rsnapshot_anacron/install.sh old mode 100644 new mode 100755 index a544c33..17d2b36 --- a/rsnapshot_anacron/install.sh +++ b/rsnapshot_anacron/install.sh @@ -7,21 +7,21 @@ set -euo pipefail user="$USER" -mkdir -p $user/scripts -cp -r ../anacron $user/scripts/ -cd $user/scripts/ +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 [[ "$sintalled" == "" ]]; then +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 install anacron +sudo apt install anacron snapshot=$(grep "^snapshot_root.*$" /etc/rsnapshot.conf|cut -f 2) @@ -33,7 +33,7 @@ fi tag="=^=rsnapshot_anacron=^=" if [[ $(grep "$tag" /etc/anacrontab) == "" ]]; then -sudo echo " +echo " ########################################################## # $tag # périodicité (jours), @@ -44,11 +44,9 @@ sudo echo " @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/ -" >> /etc/anacrontab +" | sudo tee -a /etc/anacrontab fi -ln -s $base ~/.anacron - # Test if snapshot dir is set source $base/rsnapshot_common if [[ "$SNAPSHOT_ROOT" == "" ]] ; then diff --git a/rsnapshot_anacron/rsnapshot_common b/rsnapshot_anacron/rsnapshot_common index e82ee9f..48237df 100644 --- a/rsnapshot_anacron/rsnapshot_common +++ b/rsnapshot_anacron/rsnapshot_common @@ -19,7 +19,7 @@ ENABLE_CRON=no # SNAPSHOT_ROOT="" -RSNAPSHOT="/usr/bin/rsnapshot -t" +RSNAPSHOT="/usr/bin/rsnapshot" function backup() { From 58e6285d24a54eaad40bfc02676aa67a33cf205d Mon Sep 17 00:00:00 2001 From: nojhan Date: Sat, 3 Mar 2018 14:42:42 +0100 Subject: [PATCH 9/9] git push default simple --- .gitconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitconfig b/.gitconfig index 5ac9949..4fea866 100644 --- a/.gitconfig +++ b/.gitconfig @@ -20,3 +20,5 @@ diff = less -R +'/^\\@\\@\\s' [color] ui = auto +[push] + default = simple