]> git.sev.monster Git - dotfiles.git/blobdiff - base/.zprofile
partially revert zsh refactor, fix zsh conf bugs
[dotfiles.git] / base / .zprofile
index 39abb7d416ffc5e4e6c4da52a06bf6320f9cd497..f02872800c6c44d36fb806f664cf9fdef6e1f75c 100644 (file)
@@ -1,5 +1,68 @@
-case "`uname`" in *BSD*)
-       mkdir -m 700 "/tmp/home-$LOGNAME" > /dev/null 2>&1
-       unlink "$HOME/tmp" > /dev/null 2>&1
-       ln -sFh "/tmp/home-$LOGNAME" "$HOME/tmp";;
-esac
+### exports
+## reset PATH to prevent /etc/zprofile from changing it
+# some distros put non-interactive PATH in env and interactive PATH in profile;
+# we want to make sure to always use ours regardless
+if [[ -v _sev_backup_path ]] {
+    path=("${_backup_path[@]}" "${path[@]}")
+    export PATH
+    unset _sev_backup_path
+}
+## common
+export EDITOR=vim
+export PAGER=less
+## grep
+# XXX: deprecated in GNU
+export GREP_OPTIONS=--color=auto
+## histfile
+export HISTFILE=~/.histfile
+export HISTSIZE=1000
+export SAVEHIST=1000
+## python
+export PYTHONSTARTUP=~/.pythonrc
+## perl
+[[ -v commands[perl] ]] && eval $(perl -I $XDG_DATA_HOME/perl5/lib/perl5 -Mlocal::lib=$XDG_DATA_HOME/perl5 2>/dev/null)
+
+### ssh agents
+# NOTE: preferred order of agents to check: okcagent, gnupg, openssh
+#       first block takes care of okcagent and openssh, second handles gnupg
+if [[ ! -v SSH_AUTH_SOCK && ( -v commands[okc-ssh-agent] ||
+      ( -v commands[ssh-agent] && ! -v commands[gpg] ) ) ]] {
+    okc=${commands[okc-ssh-agent]:+okc-}
+    agentfile=~/tmp/${okc}ssh-agent-exports
+    typeset sock=
+    typeset -i pid=
+    if [[ -f "$agentfile" ]] {
+        IFS=$'\0' read -r sock pid <"$agentfile"
+    }
+    if [[ -S "$sock" && $pid > 0 ]] && kill -0 $pid; then
+        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`
+        echo -n "$SSH_AUTH_SOCK"$'\0'$SSH_AGENT_PID >!$agentfile
+    fi
+    unset okc agentfile sock pid
+} elif [[ -v commands[gpg] && ! -S $_GNUPG_SOCK_DEST && \
+          ( ! -v SSH_AUTH_SOCK || -v DISPLAY ) ]] {
+    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 \
+        '/echo GPG agent pid ${get serverpid}' /bye
+    [[ ! -v SSH_AUTH_SOCK ]] && \
+        export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
+}
+
+### gpg socket
+if [[ -v _GNUPG_SOCK_SRC && -v _GNUPG_SOCK_DEST && -S $_GNUPG_SOCK_DEST ]] {
+    unlink $_GNUPG_SOCK_SRC >/dev/null 2>&1
+    mv $_GNUPG_SOCK_DEST $_GNUPG_SOCK_SRC >/dev/null
+}
+
+### load site-specific
+if [[ -f ~/.zprofile.local ]] { source ~/.zprofile.local }
+
+# vim: set et sts=4 sw=4 ts=8 tw=79 :
This page took 0.032909 seconds and 4 git commands to generate.