Skip to content

Instantly share code, notes, and snippets.

@a7madgamal
Last active January 1, 2016 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save a7madgamal/8111860 to your computer and use it in GitHub Desktop.
Save a7madgamal/8111860 to your computer and use it in GitHub Desktop.
path bookmarks for terminal,"sudo apt-get install apparix" then append the gist code to the ~/.bashrc file =========================================== syntax: cd /very/long/bath/to/very/deep/folder/ >bm notsolong now wherever you are,this command takes you to your bookmark >to notsolong
function to () {
if test "$2"; then
cd "$(apparix "$1" "$2" || echo .)";
else
cd "$(apparix "$1" || echo .)";
fi
pwd
}
function bm () {
if test "$2"; then
apparix --add-mark "$1" "$2";
elif test "$1"; then
apparix --add-mark "$1";
else
apparix --add-mark;
fi
}
function portal () {
if test "$1"; then
apparix --add-portal "$1";
else
apparix --add-portal;
fi
}
function portal () {
if test "$1"; then
apparix --add-portal "$1";
else
apparix --add-portal;
fi
}
# function to generate list of completions from .apparixrc
function _apparix_aliases ()
{ cur=$2
dir=$3
COMPREPLY=()
if [ "$1" == "$3" ]
then
COMPREPLY=( $( cat $HOME/.apparix{rc,expand} | \
grep "j,.*$cur.*," | cut -f2 -d, ) )
else
dir=`apparix -favour rOl $dir 2>/dev/null` || return 0
eval_compreply="COMPREPLY=( $(
cd "$dir"
\ls -d *$cur* | while read r
do
[[ -d "$r" ]] &&
[[ $r == *$cur* ]] &&
echo \"${r// /\\ }\"
done
) )"
eval $eval_compreply
fi
return 0
}
# command to register the above to expand when the 'to' command's args are being expanded
complete -F _apparix_aliases to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment