Created
April 16, 2019 18:25
-
-
Save qutek/df599064e89de0f88718c1cb72bd451b to your computer and use it in GitHub Desktop.
[Custom cd function] Custom bash function to cd in my local server directory with autocomplete
This file contains hidden or 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
# Use it with `goto project` | |
goto () { | |
# cancel if no arguments | |
if [ -z "$1" ]; then | |
echo "Mau goto kemana??" | |
return 0 | |
fi | |
local UPPER=$(printf "%s" "$1" | tr '[:lower:]' '[:upper:]'); | |
local P_DIR="/Users/qutek/LocalServer/_$UPPER"; | |
# if directory exists | |
if [ -d "$P_DIR" ]; then | |
cd "$P_DIR"; | |
else | |
echo "$P_DIR gak ada!!"; | |
return 0; | |
fi | |
} | |
complete -W "project mayven deft" goto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment