bash function console; pretty darn useful

This commit is contained in:
Frank Villaro-Dixon 2013-12-26 17:54:54 +01:00
parent 7a53b18ed5
commit 9e81349191
3 changed files with 61 additions and 5 deletions

View file

@ -103,7 +103,7 @@ case $1 in
;;
"init-all")
xrandr | grep "VGA1 disconnected" > /dev/null
xrandr | grep "VGA2 disconnected" > /dev/null
if [ $? -eq 0 ]
then
$0 monitor laptop

49
bashrc
View file

@ -135,6 +135,7 @@ alias BSI3='cd "$BSI3_PATH"'
OCTOPUS=~/.my_utils/octopus.sh
alias dual='$OCTOPUS monitor dual'
alias laptop='$OCTOPUS monitor laptop'
alias programming='$OCTOPUS monitor programming'
alias extern='$OCTOPUS monitor extern'
alias clone='$OCTOPUS monitor clone'
@ -158,7 +159,6 @@ alias o='octave'
alias cdu='cdu -idh'
alias dus='du -sh * | sort -h'
alias im='profanity'
# }}}
@ -169,9 +169,9 @@ alias im='profanity'
function cd #{{{
{
if [ $# -eq 0 ]; then
builtin cd ~ && ls
builtin cd ~ && cons_set > /dev/null && ls
else
builtin cd "$*" && ls
builtin cd "$*" && cons_set > /dev/null && ls
fi
}
#}}}
@ -468,6 +468,49 @@ function op
esac
}
function vim
{
local STTYOPTS="$(stty --save)"
stty stop '' -ixoff
command vim "$@"
stty "$STTYOPTS"
}
#CONS(OLE) function, a pretty useful functions that keeps track of
# the lasts whereabouts (in terms of folders) of the terminal
CONS_ROOT_DIRECTORY=/dev/shm/cons_$USER
function cons
{
if [ ! -d $CONS_ROOT_DIRECTORY ]; then
mkdir $CONS_ROOT_DIRECTORY
fi;
if [ $# -eq 0 ]; then
for f in $CONS_ROOT_DIRECTORY/*; do
echo -e "`echo $f|rev|cut -d/ -f1|rev` >>\n\t`cat $f`"
done
elif [ $# -eq 1 ]; then
if [ -e $CONS_ROOT_DIRECTORY/$1 ]; then
cd $(cat $CONS_ROOT_DIRECTORY/$1)
else
echo $1 does not exist
fi;
fi;
}
function cons_set
{
TTY=$(tty)
if [ ! -d $CONS_ROOT_DIRECTORY ]; then
mkdir $CONS_ROOT_DIRECTORY
fi;
TTYNO=`echo $TTY | cut -d/ -f 4`
pwd > $CONS_ROOT_DIRECTORY/$TTYNO
}
# }}}
SSHAGENT=/usr/bin/ssh-agent

View file

@ -105,9 +105,22 @@ hi ColorColumn ctermbg=lightblue guibg=lightgrey
"MAKEFILES
map <F5> :make
map <F6> :e %:r.h
map <F6> :vsplit %:r.h
map <F7> :split %:r.h
"TIPS : :copen :cclose :cw
" Save on Ctrl-S {{{
" If the current buffer has never been saved, it will have no name,
" call the file browser to save it, otherwise just save it.
command -nargs=0 -bar Update if &modified
\| if empty(bufname('%'))
\| browse confirm write
\| else
\| confirm write
\| endif
\|endif
nnoremap <silent> <C-S> :<C-u>Update<CR>
"}}}
"SKELETONS {{{