Last active
March 16, 2016 12:07
-
-
Save eruffaldi/5b35247de5b3458c9b7e to your computer and use it in GitHub Desktop.
Named working locations or initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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