Skip to content

Instantly share code, notes, and snippets.

@eruffaldi
Last active March 16, 2016 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eruffaldi/5b35247de5b3458c9b7e to your computer and use it in GitHub Desktop.
Save eruffaldi/5b35247de5b3458c9b7e to your computer and use it in GitHub Desktop.
Named working locations or initialization
#!/bin/bash
function _xcdall()
{
#enter below space separated your commands
eval "$1='pd1 xxx u14'"
}
function xcd() {
local arrIN sep before after what
what=$1
before=${what%%"/"*}
after=${what:$((${#before}+1))}
case $before in
pd1)
echo "Working on PD Proposal H2020"
cd ~/Documents/work/xxx/xxx/proposal
;;
xxx)
cd ~/Documents/work/what
;;
u14)
cd ~/Documents/VMs/RemediVM1404
;;
*)
local ALL
_xcdall ALL
echo "Unknown $before. Options are: $ALL"
return
;;
esac
if [ -n "$after" ]; then
cd $after
fi
}
function _xcd() {
local cur ALL
cur=$2
_xcdall ALL
COMPREPLY=( $( compgen -W "$ALL" -- "$cur" ) )
} &&
complete -F _xcd xcd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment