summaryrefslogtreecommitdiff
path: root/02_Functions.zsh
diff options
context:
space:
mode:
Diffstat (limited to '02_Functions.zsh')
-rw-r--r--02_Functions.zsh63
1 files changed, 63 insertions, 0 deletions
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 <hugues@hiegel.fr>
+##
+## 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/^/ /'
+}
+