ro and roset are getting better
This commit is contained in:
parent
c01e8b69a6
commit
d16425273d
2 changed files with 69 additions and 4 deletions
72
bashrc
72
bashrc
|
@ -3,6 +3,16 @@ shopt -s histappend
|
|||
PROMPT_COMMAND='history -a'
|
||||
|
||||
|
||||
#For autocompletions
|
||||
|
||||
function have() { return 1; } #Some files use have: suppress warnings (yeah: 2>.. )
|
||||
function _completion_loader() { return 1; }
|
||||
#cd /usr/share/bash-completion/completions
|
||||
#for i in *; do source ./$i; done
|
||||
#unset have
|
||||
#unset _completion_loader
|
||||
|
||||
|
||||
#####ON DEFINIT LES COULEURS
|
||||
red='\033[31m'
|
||||
RED='\033[31m\033[01m'
|
||||
|
@ -211,20 +221,74 @@ extract()
|
|||
|
||||
|
||||
## FIXME TO IMPROVE WITH VARIOUS locations (ex: ro 1; ro 2; ro 3)
|
||||
ro()
|
||||
RO_ROOT_DIRECTORY=/dev/shm/ro_$USER
|
||||
|
||||
function ro()
|
||||
{ # {{{
|
||||
if [ ! -d $RO_ROOT_DIRECTORY ]; then
|
||||
mkdir $RO_ROOT_DIRECTORY
|
||||
fi
|
||||
|
||||
if [ -z $1 ]; then
|
||||
my_root_set=`cat $RO_ROOT_DIRECTORY/default 2>/dev/null`
|
||||
else
|
||||
my_root_set=`cat $RO_ROOT_DIRECTORY/$1 2>/dev/null`
|
||||
fi;
|
||||
|
||||
if [ -n "$my_root_set" ]; then
|
||||
cd $my_root_set;
|
||||
else
|
||||
echo "root not set ! set it with roset !";
|
||||
if [ -z $1 ]; then
|
||||
echo -e "root for flag $1 not set.\nSet-it with roset $1"
|
||||
else
|
||||
echo "root not set ! set it with roset !";
|
||||
fi
|
||||
fi;
|
||||
} # }}}
|
||||
|
||||
roset()
|
||||
function roset()
|
||||
{ # {{{
|
||||
my_root_set="`pwd`";
|
||||
if [ ! -d $RO_ROOT_DIRECTORY ]; then
|
||||
mkdir $RO_ROOT_DIRECTORY
|
||||
fi
|
||||
|
||||
if [ -z $1 ]; then
|
||||
pwd > $RO_ROOT_DIRECTORY/default
|
||||
else
|
||||
pwd > $RO_ROOT_DIRECTORY/$1
|
||||
fi
|
||||
} # }}}
|
||||
|
||||
_RoRosetCompletion()
|
||||
{
|
||||
local cur # Pointer to current completion word.
|
||||
|
||||
COMPREPLY=() # Array variable storing the possible completions.
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
_ROSET_ACTUAL_DIR=`pwd`
|
||||
builtin cd $RO_ROOT_DIRECTORY
|
||||
ALL_POSSIBLE_WORDS=(*)
|
||||
builtin cd $_ROSET_ACTUAL_DIR
|
||||
|
||||
# echo "Cur: >>$cur<<"
|
||||
|
||||
for i in ${ALL_POSSIBLE_WORDS[@]}; do
|
||||
# echo ">>>$i"
|
||||
WORD=$(echo $i | grep "^$cur" | tr -d ' ') #ugly
|
||||
if [ $WORD ]; then
|
||||
# echo "blah!: >>$WORD<<"
|
||||
COMPREPLY+=("$WORD");
|
||||
fi;
|
||||
done
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _RoRosetCompletion -o filenames ro roset
|
||||
|
||||
|
||||
# }}}
|
||||
|
||||
SSHAGENT=/usr/bin/ssh-agent
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!-- vim: set ts=4 sw=4 noet: -->
|
||||
<head>
|
||||
|
|
Loading…
Reference in a new issue