Expand frequent-directory & check dir exists
This commit is contained in:
parent
b9373430b0
commit
0951c445f4
25
zshrc
25
zshrc
@ -191,17 +191,22 @@ fi
|
||||
|
||||
# Frequntly used directories
|
||||
function frequent-directory() {
|
||||
# Replace - with _ in environment variable name.
|
||||
local name=$(echo $1 | sed 's/^\(.*\)=.*$/\1/g' | sed 's/-/_/g')
|
||||
local value=$(echo $1 | sed 's/^.*=\(.*$\)/\1/g')
|
||||
export $name=$value
|
||||
hash -d $1
|
||||
if [ -d "$2" ]; then
|
||||
# Replace - with _ in environment variable name.
|
||||
local name=${1//-/_}
|
||||
local value=$2
|
||||
export $name=$value
|
||||
hash -d $1
|
||||
fi
|
||||
}
|
||||
frequent-directory Projects="$HOME/Projects"
|
||||
frequent-directory Sandbox="$HOME/Sandbox"
|
||||
frequent-directory config="$HOME/.config"
|
||||
frequent-directory local="$HOME/.local"
|
||||
frequent-directory cache="$HOME/.cache"
|
||||
frequent-directory Desktop "$HOME/Desktop"
|
||||
frequent-directory Documents "$HOME/Documents"
|
||||
frequent-directory Downloads "$HOME/Downloads"
|
||||
frequent-directory Projects "$HOME/Projects"
|
||||
frequent-directory Sandbox "$HOME/Sandbox"
|
||||
frequent-directory cache "$HOME/.cache"
|
||||
frequent-directory config "$HOME/.config"
|
||||
frequent-directory local "$HOME/.local"
|
||||
|
||||
# Load work related config
|
||||
[ -f ~/.config/work/zshrc ] && source ~/.config/work/zshrc
|
||||
|
Loading…
x
Reference in New Issue
Block a user