repo: Add XDG user dirs config + Update zsh hashes

Create named directories to every visible folder in $HOME for greater
portability.
Set the CDABLE_VARS zsh option.
This commit is contained in:
2020-11-03 15:11:30 +01:00
parent d0aa4ea65b
commit ddb2114a87
3 changed files with 39 additions and 14 deletions

View File

@@ -112,18 +112,27 @@
alias date='env LC_TIME=tk_TM date'
# Named directories
hash -d docs=~/docs
hash -d down=~/downloads
hash -d pics=~/pics
hash -d proj=~/projs
for dir in "$HOME"/[^.]*(/); do
[[ ! ${dir:t} =~ " " ]] || continue
hash -d ${dir:t}="$dir"
done
hash -d cheat=~docs/cheat_sheets
hash -d dot{,s}=~proj/dotfiles
hash -d uni=~docs/uni
hash -d work=~docs/work
# Use the first match in ~uni/[0-9][0-9]-{So,Wi}Se sorted in descending
# numeric order (most recent semester). The echo is necessary as else
# filename generation will include the wise= and nothing is matched. TODO!
hash -d sose="$(echo ~uni/[0-9][0-9]-SoSe(NnOn[1]))"
hash -d wise="$(echo ~uni/[0-9][0-9]-WiSe(NnOn[1]))"
hash="$(xdg-user-dir DOCUMENTS 2>/dev/null || echo docs)"
hash="$(basename "$hash")"
if (( $+nameddirs[$hash] )); then
hash -d cheat=~$hash/cheat_sheets
hash -d uni=~$hash/uni
hash -d work=~$hash/work
fi
unset hash
if (( $+nameddirs[projs] )); then
hash -d dot{,s}=~projs/dotfiles
fi
if (( $+nameddirs[uni] )); then
# Use the first match in ~uni/[0-9][0-9]-{So,Wi}Se sorted in descending
# numeric order (most recent semester). The echo is necessary as else
# filename generation will include the wise= and nothing is matched.
# TODO!
hash -d sose="$(echo ~uni/[0-9][0-9]-SoSe(NnOn[1]))"
hash -d wise="$(echo ~uni/[0-9][0-9]-WiSe(NnOn[1]))"
fi