Expand frequent-directory & check dir exists

This commit is contained in:
Kenneth Benzie 2024-04-18 21:59:29 +01:00
parent b9373430b0
commit 0951c445f4

19
zshrc
View File

@ -191,17 +191,22 @@ fi
# Frequntly used directories
function frequent-directory() {
if [ -d "$2" ]; then
# 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')
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