]> git.sev.monster Git - dotfiles.git/blobdiff - base/.zprofile
zprofile: remove unnecessary variable
[dotfiles.git] / base / .zprofile
index 648cf5522f469b32a70b567f5fe31c4254e00df0..2a26dbb161158058f983cb6e162b8677b04770d4 100644 (file)
@@ -44,13 +44,8 @@ function _sev_zcleanup {
             }
         }
         # reset GNUPGHOME if we removed our own dir
             }
         }
         # reset GNUPGHOME if we removed our own dir
-        if [[ $GNUPGHOME =~ '/.ssh_forward/\d+/*$' && ! -e $GNUPGHOME ]] {
-            x=$GNUPGHOME
-            [[ -o GLOB_ASSIGN ]]; y=$?
-            setopt GLOB_ASSIGN
-            GNUPGHOME=$GNUPGHOME/../..(:a)
-            (( y != 0 )) && unsetopt GLOB_ASSIGN
-        }
+        if [[ $GNUPGHOME =~ '/.ssh_forward/\d+/*$' && ! -e $GNUPGHOME ]]
+            GNUPGHOME=${GNUPGHOME%$MATCH}
     }
 
     ## tmp
     }
 
     ## tmp
@@ -88,8 +83,9 @@ if [[ ! -v _sev_setup_path || -o login ]] {
     # NOTE: /usr/{local,pkg,games} are unix/bsdisms
     # XXX: PREFIX not validated, non-posix but Termux uses it
     syspath=("$path[@]")
     # NOTE: /usr/{local,pkg,games} are unix/bsdisms
     # XXX: PREFIX not validated, non-posix but Termux uses it
     syspath=("$path[@]")
-    path=({~,~/.local,{$PREFIX,}{,/opt,/usr{,/local,pkg}}}/sbin
-          {~,~/.local,{$PREFIX,}{,/opt,/usr{,/local,pkg}}}/bin
+    path=(~/{s,}bin
+          {~/.local,{$PREFIX,}{,/opt,/usr{,/local,pkg}}}/sbin
+          {~/.local,{$PREFIX,}{,/opt,/usr{,/local,pkg}}}/bin
           /usr/{X11R{7,6}/bin,games})
     ((len=$#path))
     path=("$path[@]" "$syspath[@]")
           /usr/{X11R{7,6}/bin,games})
     ((len=$#path))
     path=("$path[@]" "$syspath[@]")
@@ -104,7 +100,7 @@ if [[ ! -v _sev_setup_path || -o login ]] {
     }
     # shift valid system paths to the front if there are any left
     ((len > 0 && len < $#path)) && path=("${(@)path[len + 1, -1]}" "${(@)path[1, len]}")
     }
     # shift valid system paths to the front if there are any left
     ((len > 0 && len < $#path)) && path=("${(@)path[len + 1, -1]}" "${(@)path[1, len]}")
-    unset syspath len i j
+    unset syspath len i
     # include our zsh dir in fpath. unlike above, we always prefer our paths
     fpath=(${ZDOTDIR:-~/.zsh}/functions/{*,Completions/*}(N) "$fpath[@]")
     # FPATH is not exported by default
     # include our zsh dir in fpath. unlike above, we always prefer our paths
     fpath=(${ZDOTDIR:-~/.zsh}/functions/{*,Completions/*}(N) "$fpath[@]")
     # FPATH is not exported by default
@@ -290,33 +286,39 @@ if [[ -v commands[gpg-connect-agent] && ( ! -v _sev_setup_gpgagent ||
     if {$p} {
         print -nP '%F{blue}>>>%f GPG: '
         if [[ -v _sev_setup_gpg_forward ]] {
     if {$p} {
         print -nP '%F{blue}>>>%f GPG: '
         if [[ -v _sev_setup_gpg_forward ]] {
-            a=agent
-            print -nP '%F{yellow}Forwarded%f '
-        } else { a=Agent }
-        print -nP '%F{green}'
+            print -nP '%F{yellow}Forwarded agent '
+        } else {
+            print -nP '%F{green}Agent '
+        }
     }
     gpg-connect-agent /bye >/dev/null 2>&1
     if [[ $? -ne 0 ]] {
     }
     gpg-connect-agent /bye >/dev/null 2>&1
     if [[ $? -ne 0 ]] {
-        $p && print -P '%F{red}$a communication error'
+        $p && print -P '%F{red}communication error'
     } else {
     } else {
-        if [[ ${+GPG_TTY} -eq 0 && -o interactive ]]
-            export GPG_TTY=$(tty)
-        if [[ ( -v DISPLAY || -v WAYLAND_DISPLAY ) &&
-              ${PINENTRY_USER_DATA/USE_TTY=0} == $PINENTRY_USER_DATA ]]
-            export PINENTRY_USER_DATA=USE_TTY=$((
-              ${+DISPLAY} + ${+WAYLAND_DISPLAY} == 0))
-        # XXX: don't know if gpg-agent supports comments after directives
-        # XXX: path could have #
-        sed -Ei 's#^([[:space:]]*pinentry-program[[:space:]]).*$#\1'${commands[pinentry]:-/dev/null}'#' \
-          ${GNUPGHOME:-~/.gnupg}/gpg-agent.conf
-        # XXX: could probably check for changes before doing this to save perf
-        gpg-connect-agent RELOADAGENT UPDATESTARTUPTTY /bye >/dev/null 2>&1
-        $p && gpg-connect-agent /subst /serverpid \
-                "/echo $a pid \${get serverpid} on $GPG_TTY" /bye
+        if [[ ! -v _sev_setup_gpg_forward ]] {
+            if [[ ${+GPG_TTY} -eq 0 && -o interactive ]]
+                export GPG_TTY=$(tty)
+            if [[ ( -v DISPLAY || -v WAYLAND_DISPLAY ) &&
+                  ${PINENTRY_USER_DATA/USE_TTY=0} == $PINENTRY_USER_DATA ]]
+                export PINENTRY_USER_DATA=USE_TTY=$((
+                  ${+DISPLAY} + ${+WAYLAND_DISPLAY} == 0))
+            # XXX: don't know if gpg-agent supports comments after directives
+            # XXX: path could have #
+            sed -Ei 's#^([[:space:]]*pinentry-program[[:space:]]).*$#\1'${commands[pinentry]:-/dev/null}'#' \
+              ${GNUPGHOME:-~/.gnupg}/gpg-agent.conf
+            # XXX: could check for changes before doing this to save perf
+            gpg-connect-agent RELOADAGENT UPDATESTARTUPTTY /bye >/dev/null 2>&1
+            if {$p} {
+                gpg-connect-agent /subst /serverpid \
+                  "/echo pid \${get serverpid} on $GPG_TTY" /bye 2>/dev/null
+                print -nP '%f'
+            }
+        } elif {$p} {
+            print -P '%f'
+        }
         export _sev_setup_gpgagent=
     }
         export _sev_setup_gpgagent=
     }
-    $p && print -nP '%f'
-    unset p a
+    unset p
 }
 
 ### ssh agent
 }
 
 ### ssh agent
@@ -328,8 +330,7 @@ if [[ ! -v _sev_setup_ssh ]] {
     if [[ ! -v SSH_AUTH_SOCK && ( -v commands[okc-ssh-agent] ||
           ( -v commands[ssh-agent] && ! -v commands[gpg] ) ) ]] {
         okc=${commands[okc-ssh-agent]:+okc-}
     if [[ ! -v SSH_AUTH_SOCK && ( -v commands[okc-ssh-agent] ||
           ( -v commands[ssh-agent] && ! -v commands[gpg] ) ) ]] {
         okc=${commands[okc-ssh-agent]:+okc-}
-        t=${_sev_tmp:-${TMPDIR:-${TEMP:-${TMP:-/tmp}}}}
-        e=$t/${okc}ssh-agent-exports
+        e=$_sev_tmp/${okc}ssh-agent-exports
         typeset sock=
         typeset -i pid=
         if [[ -f $e ]] {
         typeset sock=
         typeset -i pid=
         if [[ -f $e ]] {
@@ -340,20 +341,21 @@ if [[ ! -v _sev_setup_ssh ]] {
             export SSH_AUTH_SOCK=$sock
             export SSH_AGENT_PID=$pid
         else
             export SSH_AUTH_SOCK=$sock
             export SSH_AGENT_PID=$pid
         else
-            e='TMPDIR=$t ${okc}ssh-agent'
             # TODO: ensure ssh-agent path looks legit to avoid unsafe eval?
             # XXX: doesn't appear to be any other way to handle redirection.
             #      because eval needs to write to current scope environment
             #      subshells can't be used to capture output and print.
             # TODO: ensure ssh-agent path looks legit to avoid unsafe eval?
             # XXX: doesn't appear to be any other way to handle redirection.
             #      because eval needs to write to current scope environment
             #      subshells can't be used to capture output and print.
+            c='TMPDIR=$_sev_tmp ${okc}ssh-agent'
             if [[ -o interactive ]] {
             if [[ -o interactive ]] {
-                eval $(eval $=e)
+                eval $(eval $=c)
                 print -nP '%f'
             } else {
                 print -nP '%f'
             } else {
-                eval $(eval $=e) >/dev/null 2>&1
+                eval $(eval $=c) >/dev/null 2>&1
             }
             echo -n $SSH_AUTH_SOCK$'\0'$SSH_AGENT_PID >!$e
             }
             echo -n $SSH_AUTH_SOCK$'\0'$SSH_AGENT_PID >!$e
+            unset c
         fi
         fi
-        unset okc e sock pid
+        unset okc e sock pid
     } elif [[ ! -v SSH_AUTH_SOCK && -v commands[gpg] ]] {
         # since gpg should have been started above, just export and notify
         if [[ -o interactive ]] {
     } elif [[ ! -v SSH_AUTH_SOCK && -v commands[gpg] ]] {
         # since gpg should have been started above, just export and notify
         if [[ -o interactive ]] {
This page took 0.040098 seconds and 4 git commands to generate.