From 76dd39c8642a87f4b06a28e39b9cc5a4547ce3cd Mon Sep 17 00:00:00 2001 From: Scott Ames Date: Tue, 19 Mar 2024 08:37:08 -0700 Subject: [PATCH] fix(fish/distrobox): load order, after setenv + gum bin logic --- home/dot_setenv | 7 +++++++ .../conf.d/{__distrobox.fish => _distrobox.fish} | 15 +++++++++------ .../fish/custom_functions.d/distrobox_enter.fish | 8 ++------ 3 files changed, 18 insertions(+), 12 deletions(-) rename home/private_dot_config/fish/conf.d/{__distrobox.fish => _distrobox.fish} (54%) diff --git a/home/dot_setenv b/home/dot_setenv index f126849e..70cb3485 100644 --- a/home/dot_setenv +++ b/home/dot_setenv @@ -66,6 +66,7 @@ setenv SHRUG "¯\\_(ツ)_/¯" setenv TERM "xterm-256color" setenv TMOUT 0 setenv VAGRANT_DEFAULT_PROVIDER "virtualbox" +setenv XAUTHLOCALHOSTNAME "$(hostnamectl hostname)" setenv ZPLUG_HOME "$HOME/.zplug" setenv ZPLUG_LOADFILE "$HOME/.zsh/zplugs.zsh" @@ -77,6 +78,12 @@ $HAS_BAT \ $HAS_BAT \ && setenv MANPAGER "sh -c 'col -bx | bat -l man -p'" +setenv GUM_BIN "" +$HAS_GUM \ + && setenv GUM_BIN "gum" +$HAS_UGUM \ + && setenv GUM_BIN "ugum" + # handy unicode setenv TICK "✔" setenv CROSS "✖" diff --git a/home/private_dot_config/fish/conf.d/__distrobox.fish b/home/private_dot_config/fish/conf.d/_distrobox.fish similarity index 54% rename from home/private_dot_config/fish/conf.d/__distrobox.fish rename to home/private_dot_config/fish/conf.d/_distrobox.fish index 45e3008c..fd7dbc50 100644 --- a/home/private_dot_config/fish/conf.d/__distrobox.fish +++ b/home/private_dot_config/fish/conf.d/_distrobox.fish @@ -5,24 +5,27 @@ if status --is-login and not is_container >/dev/null - if type -q distrobox-host-exec - and type -q fzf + if test -z $GUM_BIN + and type -q distrobox-host-exec + and type -q $GUM_BIN set -l box ( begin distrobox ls | tail -n +2 | tr -s ' ' | cut -d '|' -f 2,4 | string trim | sort echo "none | shell" - end | ugum filter --timeout=10s --header="distrobox?" --placeholder="" | cut -d '|' -f 1 | string trim + end | $GUM_BIN filter --timeout=10s --header="distrobox?" --placeholder="" | cut -d '|' -f 1 | string trim ) if [ "$box" != none ] distrobox enter $box end else - if not type -q distrobox-host-exec + if test -z $GUM_BIN + printf_warn "missing GUM_BIN\n" + else if not type -q distrobox-host-exec printf_warn "missing distrobox-host-exec\n" - else if not type -q fzf - printf_warn "missing fzf\n" + else if not type -q $GUM_BIN + printf_warn "$GUM_BIN not installed!?\n" end end end diff --git a/home/private_dot_config/fish/custom_functions.d/distrobox_enter.fish b/home/private_dot_config/fish/custom_functions.d/distrobox_enter.fish index 5d59ae48..aa4fc3fd 100644 --- a/home/private_dot_config/fish/custom_functions.d/distrobox_enter.fish +++ b/home/private_dot_config/fish/custom_functions.d/distrobox_enter.fish @@ -5,15 +5,11 @@ function distrobox_enter \ set -l gumBin - if $HAS_UGUM - set gumBin ugum - else if $HAS_GUM - set gumBin gum - else + if test -z $GUM_BINZ printf_err "missing gum/ugum!" return 1 end - set -l box (distrobox ls | tail -n +2 | tr -s ' ' | cut -d ' ' -f 3,8-9 | $gumBin choose | cut -d ' ' -f 1) + set -l box (distrobox ls | tail -n +2 | tr -s ' ' | cut -d ' ' -f 3,8-9 | $GUM_BIN choose | cut -d ' ' -f 1) distrobox enter $box end