X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/c3608beb1b6da54f2e7b489571b750f582338f9f..4be2bcd2e2f69ffa226d75f6e06ca2280a164cee:/base/.zshenv?ds=sidebyside diff --git a/base/.zshenv b/base/.zshenv index 8add817..1f3e198 100644 --- a/base/.zshenv +++ b/base/.zshenv @@ -24,7 +24,8 @@ if [[ -v _sev_reset_shell || $SHLVL == 1 ]] { /usr/local/{s,}bin /usr/games) PATH=$PATH:$_sev_sys_PATH fpath=(${ZDOTDIR:-$HOME/.zsh}/functions/{*,Completions/*}(N)) - FPATH=$FPATH:$_sev_sys_FPATH + #fpath is not exported by default + export FPATH=$FPATH:$_sev_sys_FPATH # take another backup, explained in .zprofile typeset -U _backup_path _backup_path=("${path[@]}") @@ -36,24 +37,26 @@ if [[ -v _sev_reset_shell || $SHLVL == 1 ]] { export XDG_DATA_DIRS=~/.local/share:/usr/pkg/share:/usr/local/share:/usr/share export XDG_CACHE_HOME=~/tmp export XDG_RUNTIME_DIR=~/tmp + if [[ -e $XDG_CONFIG_HOME/user-dirs.dirs ]] { + source $XDG_CONFIG_HOME/user-dirs.dirs + } ## create tmp link t=${TMPDIR:-/tmp}/home-$LOGNAME - h=$HOME/tmp if [[ ! -e $t ]] { - mkdir -m 700 $t > /dev/null 2>&1 + mkdir -m 700 $t >/dev/null 2>&1 # TODO: check if dir exists after mkdir } # allow opaque entries to override link creation - if [[ ! -e $h ]] { - ln -sf $t $h > /dev/null 2>&1 + if [[ ! -e $XDG_RUNTIME_DIR ]] { + ln -sf $t $XDG_RUNTIME_DIR >/dev/null 2>&1 } - unset t h + unset t ## ssh agents # NOTE: preferred order of agents to check: okcagent, gnupg, openssh # first block takes care of okcagent and openssh, second gnupg - print -nP "%F{blue}>>>%f SSH: %F{green}" + [[ -o interactive ]] && print -nP "%F{blue}>>>%f SSH: %F{green}" if [[ ! -v SSH_AUTH_SOCK && ( -v commands[okc-ssh-agent] || ( -v commands[ssh-agent] && ! -v commands[gpg] ) ) ]] { okc=${commands[okc-ssh-agent]:+okc-} @@ -64,13 +67,19 @@ if [[ -v _sev_reset_shell || $SHLVL == 1 ]] { IFS=$'\0' read -r sock pid <$agentfile } if [[ -S $sock && $pid > 0 ]] && kill -0 $pid; then - echo "Reusing agent pid $pid" + [[ -o interactive ]] && echo "Reusing agent pid $pid" export SSH_AUTH_SOCK=$sock export SSH_AGENT_PID=$pid else # TODO: ensure ssh-agent path looks legit # to avoid unsafe eval? - eval `${okc}ssh-agent` + # NOTE: no way around doing redirection like this I think + e=${okc}ssh-agent + if [[ -o interactive ]] { + eval `$e` + } else { + eval `$e` >/dev/null 2>&1 + } echo -n $SSH_AUTH_SOCK$'\0'$SSH_AGENT_PID >!$agentfile fi unset okc agentfile sock pid @@ -79,12 +88,12 @@ if [[ -v _sev_reset_shell || $SHLVL == 1 ]] { export GPG_TTY=$(tty) export PINENTRY_USER_DATA=USE_TTY=$((!${+DISPLAY})) gpg-connect-agent UPDATESTARTUPTTY /bye >/dev/null 2>&1 - gpg-connect-agent /subst /serverpid \ + [[ -o interactive ]] && gpg-connect-agent /subst /serverpid \ '/echo GPG agent pid ${get serverpid}' /bye [[ ! -v SSH_AUTH_SOCK ]] && \ export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) } else { - echo "Pre-existing or remote agent" + [[ -o interactive ]] && echo "Pre-existing or remote agent" } ## gpg ssh forwarding