From 2b2a97c37d4aee82a9f1f18768c46810aeb3493e Mon Sep 17 00:00:00 2001 From: Frank Villaro-Dixon Date: Sun, 29 Sep 2013 18:56:07 +0200 Subject: [PATCH] study function starting to be cool --- bashrc | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/bashrc b/bashrc index 7615b15..0f31258 100644 --- a/bashrc +++ b/bashrc @@ -241,12 +241,49 @@ extract() function study() { - builtin cd "$BSI3_PATH" - echo -e "$RED WORK TO DO SOON:$BLUE" - calendar -A10 - echo -e -n "$DFT" + if [ -z $1 ]; then + STUDY_PATH='' + else + if [ -d "$BSI3_PATH$1" ]; then + STUDY_PATH="$1" + else + STUDY_PATH='' + fi + fi + + builtin cd "$BSI3_PATH$STUDY_PATH" + if [ -e calendar ]; then + echo -e "$RED WORK TO DO SOON:$BLUE" + calendar -A10 + echo -e "$DFT" + fi + ls } +_StudyCompletion() +{ # {{{ + local cur # Pointer to current completion word. + + COMPREPLY=() # Array variable storing the possible completions. + cur=${COMP_WORDS[COMP_CWORD]} + + _STUDY_ACTUAL_DIR=`pwd` + builtin cd "$BSI3_PATH" + ALL_POSSIBLE_WORDS=(*) + builtin cd "$_STUDY_ACTUAL_DIR" + + for i in ${ALL_POSSIBLE_WORDS[@]}; do +# echo ">>>$i" + WORD=$(echo $i | grep "^$cur" | tr -d ' ') #ugly + if [ $WORD ]; then + COMPREPLY+=("$WORD"); + fi; + done + + return 0 +} # }}} +complete -F _StudyCompletion -o filenames study + ## FIXME TO IMPROVE WITH VARIOUS locations (ex: ro 1; ro 2; ro 3) RO_ROOT_DIRECTORY=/dev/shm/ro_$USER @@ -288,7 +325,7 @@ function roset() } # }}} _RoRosetCompletion() -{ +{ # {{{ local cur # Pointer to current completion word. COMPREPLY=() # Array variable storing the possible completions. @@ -310,9 +347,8 @@ _RoRosetCompletion() fi; done - return 0 -} +} # }}} complete -F _RoRosetCompletion -o filenames ro roset function calc()