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:
15
.config/user-dirs.dirs
Normal file
15
.config/user-dirs.dirs
Normal file
@@ -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"
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user