diff --git a/.config/user-dirs.dirs b/.config/user-dirs.dirs new file mode 100644 index 0000000..c70a547 --- /dev/null +++ b/.config/user-dirs.dirs @@ -0,0 +1,15 @@ +# This file is read by xdg-user-dirs-update +# If you want to change or add directories, just edit the line you're +# interested in. All local changes will be retained on the next run. +# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped +# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an +# absolute path. No other format is supported. + +XDG_DESKTOP_DIR="$HOME/misc" +XDG_DOWNLOAD_DIR="$HOME/downs" +XDG_TEMPLATES_DIR="$HOME/misc" +XDG_PUBLICSHARE_DIR="$HOME/misc" +XDG_DOCUMENTS_DIR="$HOME/docs" +XDG_MUSIC_DIR="$HOME/music" +XDG_PICTURES_DIR="$HOME/pics" +XDG_VIDEOS_DIR="$HOME/vids" diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index c0a2571..0d866c5 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -37,6 +37,7 @@ setopt AUTO_PUSHD # Make cd push the old directory onto the direct setopt NO_AUTO_REMOVE_SLASH # Keeps trailing slash for directories when auto completing. # (Beware: commands will act on the target directory not the symlink with the slash) setopt NO_BEEP # Do not beep on error in ZLE. +setopt CDABLE_VARS # Expand named directories without leading '~'. setopt C_BASES # Output hexadecimal numbers in the standard C format ('16#FF' -> '0xFF'). setopt CHASE_LINKS # Resolve symbolic links to their true values when changing directory. setopt NO_CLOBBER # '>!' or '>|' must be used to truncate a file, and '>>!' or '>>|' to create a file. diff --git a/.config/zsh/plugins/alias.zsh b/.config/zsh/plugins/alias.zsh index 4b80aa1..a68643a 100644 --- a/.config/zsh/plugins/alias.zsh +++ b/.config/zsh/plugins/alias.zsh @@ -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