From: sev Date: Tue, 28 Nov 2023 18:51:22 +0000 (-0600) Subject: zsh: fixup env vars and update a comment X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/commitdiff_plain/6d4ce4aad79a55ca78eb0cc6f6795904205c3cc8?ds=sidebyside;hp=bfbd0519921f338c624addaa845dab3a633c3e02 zsh: fixup env vars and update a comment - removed graphical env vars as they aren't really doing anything. would be useful for unmanaged invocations of xorg/wayland, but I don't do those anymore. if graphical configuration is ever needed it should be added to site local rc anyway since it relies heavily on underlying system configuration. - scoped vars inside functions instead of unsetting. - scoped some arithmetic vars inside _sev_setpath that were not being unset. - added /opt///bin and /opt//bin to path per FHS. - be more aggressive in unsetting GNUPGHOME after forwarding. - updated a gpg comment for clarification while there. --- diff --git a/etc/zsh/.zprofile b/etc/zsh/.zprofile index 399456b..407c300 100644 --- a/etc/zsh/.zprofile +++ b/etc/zsh/.zprofile @@ -50,8 +50,9 @@ if [[ ! -v DBUS_SESSION_BUS_ADDRESS && -v commands[dbus-launch] ]] { # therefore, the safest way to ensure unique sockets while not having to # write specific logic for both scenarios is to simply change GNUPGHOME. # the easiest way to do this is to create a new dir and link the contents -# of GNUPGHOME to the new home. we can then replace the agent sockets -# there with the forwarded one. +# of GNUPGHOME to the new home. we can then replace all of the agent +# sockets wherever they now are with the forwarded one. in either case we +# will be overwriting the session-specific sockets. # # NOTE: since Unix sockets are not supported under Windows, this will not work # under msys, cygwin, mingw, etc., but may work under wsl2. diff --git a/etc/zsh/.zshenv b/etc/zsh/.zshenv index e20553d..0d58076 100644 --- a/etc/zsh/.zshenv +++ b/etc/zsh/.zshenv @@ -3,6 +3,8 @@ # XXX: only call after relevant vars have been set up, defined early so that # below code can utilize it after they do so function _sev_zcleanup { + local x p y + # gpg forwarding if [[ -d $_sev_gpg_forward_dir && ( -z $1 || $1 == 'gpg-forward' ) ]] { # clean up forward dirs if its session is dead or we ask for it @@ -25,7 +27,7 @@ function _sev_zcleanup { } } # reset GNUPGHOME if we removed our own dir - if [[ $GNUPGHOME =~ '/.ssh_forward/\d+/*$' && ! -e $GNUPGHOME ]] + if [[ $GNUPGHOME =~ '/.ssh_forward/\d+/*$' && ! -d $GNUPGHOME ]] GNUPGHOME=${GNUPGHOME%$MATCH} } @@ -46,8 +48,6 @@ function _sev_zcleanup { } } } - - unset x p y } function _sev_setpath { @@ -55,18 +55,19 @@ function _sev_setpath { # remove any further occurences to capture elements from the old PATH # that we did not anticipate and shift them to the front, since they are # probably important to the system + # NOTE: tied arrays path and fpath already exist typeset -gU path fpath # add as many generic paths as possible to keep the order we want # NOTE: /usr/{local,pkg,games} are unix/bsdisms # XXX: PREFIX not validated, non-posix but Termux uses it, maybe others # XXX: XDG specifies ~/.local/bin as the only user-writable dir for # executables, but we specify more; technically this is against spec - syspath=("$path[@]") - path=({{${_sev_home:-~},~}{/.local,},{$PREFIX,}{,/opt,/usr{,/local,/pkg}}}/{s,}bin + local -a syspath=("$path[@]") + path=({{${_sev_home:-~},~}{/.local,},{$PREFIX,}{,/opt,/opt/*{/*,},/usr{,/local,/pkg}}}/{s,}bin(N) {$PREFIX,}/usr/{X11R{7,6}/bin,games} # emulate Arch Linux flatpak-bindir.sh for use on other systems {${XDG_DATA_HOME:-~/.local/share},{$PREFIX,}/var/lib}/flatpak/exports/bin) - ((len=$#path)) + local -i i len=$#path path=("$path[@]" "$syspath[@]") # remove bad paths for (( i = 1; i <= $#path; i++ )) { diff --git a/etc/zsh/.zshrc b/etc/zsh/.zshrc index 8fa153d..716ca79 100644 --- a/etc/zsh/.zshrc +++ b/etc/zsh/.zshrc @@ -22,12 +22,6 @@ export SAVEHIST=1000 export PYTHONSTARTUP=${XDG_CONFIG_HOME:-~/.config}/pythonrc ## vim export VIMINIT='let$MYVIMRC=($XDG_CONFIG_HOME??($HOME."/.config"))."/vim/.vimrc"|execute"source"$MYVIMRC' -## wayland/gui env -export XDG_SESSION_TYPE=${XDG_SESSION_TYPE:-wayland} -export QT_QPA_PLATFORM=${QT_QPA_PLATFORM:-wayland-egl} -export QT_WAYLAND_DISABLE_WINDOWDECORATION=${QT_WAYLAND_DISABLE_WINDOWDECORATION:--1} -export SDL_VIDEODRIVER=${SDL_VIDEODRIVER:-wayland} -export TERMINAL=${TERMINAL:-$(whence -p konsole footclient urxvt xterm)[(f)1]} ### imports autoload -Uz zmv