From f8dfa7bf4d674d6b5a2b5c02ef484ac1d228a0e0 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 24 Jan 2012 17:18:40 +0100 Subject: -- HUGE CLEANUP -- Phase #1 --- 02_Functions.zsh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 02_Functions.zsh (limited to '02_Functions.zsh') diff --git a/02_Functions.zsh b/02_Functions.zsh new file mode 100644 index 0000000..015d277 --- /dev/null +++ b/02_Functions.zsh @@ -0,0 +1,63 @@ +## +## Part of configuration files for Zsh4 +## AUTHOR: Hugues Hiegel +## +## You are encouraged to use, modify, and redistribute +## these files with or without this notice. +## +## NO WARRANTY PROVIDED, USE AT YOUR OWN RISKS +## + +__cmd_exists git && \ +git () { + GIT=$(which -p git) + case $1 in + init|clone|config) + ;; + *) + if [ "$( ( $GIT ls-files ; $GIT ls-tree HEAD . ) 2>&- | head -n1)" = ""\ + -a \( ! -d .git -o "$($GIT rev-parse --git-dir 2>&-)" != ".git" \)\ + -a "$($GIT rev-parse --is-inside-git-dir 2>&-)" != "true" ] + then + echo >&2 "git $1: the current folder is not managed by git" + return + fi + ;; + esac + + $(which -p git) $@ +} + +__cmd_exists when && \ +when() +{ + TODAY_FILE=~/.when/.today + + $(which -p when) $@ | tail -n+3 | \ + sed 's/^\(aujourd.hui *[0-9][0-9][0-9][0-9] [A-Z][a-z]\+ [0-9][0-9][ ]*\)\(.*\)/'$c_'1;33'$_c'\1\2'$c_'0'$_c'/; + s/^\(demain *[0-9][0-9][0-9][0-9] [A-Z][a-z]\+ [0-9][0-9][ ]*\)\(.*\)/'$c_'1'$_c'\1\2'$c_'0'$_c'/; + s/^\(hier *[0-9][0-9][0-9][0-9] [A-Z][a-z]\+ [0-9][0-9][ ]*\)\(.*\)/'$c_'3'$_c'\1\2'$c_'0'$_c'/' \ + > $TODAY_FILE + + if [ -s $TODAY_FILE ] + then + preprint "À ne pas manquer" $color[red] ; echo + cat $TODAY_FILE + preprint "" $color[red] ; echo + echo + fi | sed 's/^/ /' +} + +__cmd_exists todo && \ +todo() +{ + TODO=${=$(whereis -b todo | cut -d: -f2)} + if [ $($TODO $@ | wc -l) -gt 0 ] + then + preprint "À faire" $color[yellow] && echo + $TODO $@ --force-colour + preprint "" $color[yellow] && echo + echo + fi | sed 's/^/ /' +} + -- cgit v1.2.3