X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/c7e3e126ca2bfe463d344260b73b8c044e203ea0..2ec9d5520cdc37052ab071fdf639272fd10f277b:/base/.zprofile?ds=sidebyside diff --git a/base/.zprofile b/base/.zprofile index 1131a98..1abd5b5 100644 --- a/base/.zprofile +++ b/base/.zprofile @@ -32,8 +32,9 @@ if [[ ! -v _sev_setup_path || -o login ]] { # add as many generic paths as possible to keep the order we want # NOTE: /usr/{local,pkg,games} are unix/bsdisms syspath=("$path[@]") - path=({~/,/,/usr/}sbin /opt/{s,}bin /usr/local/{s,}bin /usr/pkg/{s,}bin - /usr/X11R{7,6}/bin /usr/games {~/,/,/usr/}bin) + path=({~,~/.local,,/usr,/opt,/usr/local,/usr/pkg}/sbin + {~,~/.local,,/usr,/opt,/usr/local,/usr/pkg}/bin + /usr/X11R{7,6}/bin /usr/games) ((len=$#path)) path=("$path[@]" "$syspath[@]") # remove nonexistent and duplicate paths @@ -97,17 +98,24 @@ if [[ ! -v _sev_setup_xdg ]] { # NOTE: include and then remove CONFIG_HOME and DATA_HOME to ensure they # are not present in the array if it was added before we got to it typeset -UT XDG_CONFIG_DIRS xdg_config_dirs - typeset -UT XDG_DATA_DIRS xdg_data_dirs - export XDG_CONFIG_HOME=$HOME/etc - xdg_config_dirs=($XDG_CONFIG_HOME $HOME/.config + export XDG_CONFIG_HOME=~/etc + mkdir -p $XDG_CONFIG_HOME + xdg_config_dirs=($XDG_CONFIG_HOME ~/.config {/opt,/usr/local,/usr/pkg,}/etc/xdg "${XDG_CONFIG_DIRS:+${xdg_config_dirs[@]}}") export XDG_CONFIG_DIRS=${XDG_CONFIG_DIRS#$XDG_CONFIG_HOME} - export XDG_DATA_HOME=$HOME/share - xdg_data_dirs=($XDG_DATA_HOME $HOME/.local/share + + typeset -UT XDG_DATA_DIRS xdg_data_dirs + export XDG_DATA_HOME=~/share + mkdir -p $XDG_DATA_HOME + xdg_data_dirs=($XDG_DATA_HOME ~/.local/share /{opt,usr/local,usr/pkg,usr}/share "${XDG_DATA_DIRS:+${xdg_data_dirs[@]}}") export XDG_DATA_DIRS=${XDG_DATA_DIRS#$XDG_DATA_HOME} + + export XDG_STATE_HOME=~/var/lib + mkdir -p $XDG_STATE_HOME + # use our custom tmp for cache and runtime export XDG_CACHE_HOME=$_sev_tmp/.xdg.cache export XDG_RUNTIME_DIR=$_sev_tmp/.xdg.runtime @@ -119,8 +127,10 @@ if [[ ! -v _sev_setup_xdg ]] { elif [[ -e $x ]]; then rm -rf $x 2>/dev/null fi + # XXX: cache does not have to be 700 according to spec mkdir -m700 $x 2>/dev/null done + # source user dirs after other vars [[ -e $XDG_CONFIG_HOME/user-dirs.dirs ]] && emulate sh -c "source $XDG_CONFIG_HOME/user-dirs.dirs" @@ -155,6 +165,8 @@ if [[ ! -v _sev_setup_xdg ]] { # would open up too many edge cases where it wouldn't work or be clunky # (e.g. asking for password twice) to make it worth it. if [[ ! -v _sev_setup_agents ]] { + export GNUPGHOME=~/etc/gnupg + function _socketpath { # dirs are percent-encoded: https://stackoverflow.com/a/64312099 echo ${1//(#b)%([[:xdigit:]](#c2))/${(#):-0x$match[1]}}