diff options
author | Martin Polden <mpolden@mpolden.no> | 2024-01-05 21:42:19 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2024-01-16 10:26:59 +0100 |
commit | f0dd2e0d93e639478f969e1ce37e16fc5a546930 (patch) | |
tree | efc94ce09052a52a0784721bdce91aa534cb27b4 | |
parent | 8cf4c07b6ef56cf913e454de2bfa9686520e29dd (diff) |
fish: skip some parts for non-interactive shell
-rw-r--r-- | config.fish | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/config.fish b/config.fish index 691cf03..5e872cc 100644 --- a/config.fish +++ b/config.fish @@ -41,6 +41,15 @@ function cond-alias end end +# Unbind functions that are only used to setup config +function cleanup + if not is-command brew + functions -e brew-fzf + end + functions -e path-prepend path-append cdpath-append is-command cond-alias \ + alias-diff alias-ls cleanup +end + ########## Environment ########## # Locale @@ -157,6 +166,12 @@ if is-command mvn set -gx MAVEN_OPTS "-Djava.awt.headless=true" end +# Next config is only relevant for interactive use +if not status is-interactive + cleanup + return 0 +end + ########## Aliases ########## # Display ANSI art typically found .nfo files correctly @@ -315,8 +330,7 @@ end ########## Extensions ########## -if status is-interactive - and source "$HOMEBREW_PREFIX/opt/fzf/shell/key-bindings.fish" 2> /dev/null +if source "$HOMEBREW_PREFIX/opt/fzf/shell/key-bindings.fish" 2> /dev/null fzf_key_bindings end @@ -338,9 +352,7 @@ set -g fish_prompt_pwd_dir_length 0 set -g fish_color_autosuggestion 8a8a8a # Print message if reboot is required -if status is-interactive - and [ -n "$TERM" ] - and [ -f /var/run/reboot-required ] +if [ -n "$TERM" -a -f /var/run/reboot-required ] echo "reboot required" end @@ -348,8 +360,4 @@ end source $HOME/.config/fish/local.fish 2> /dev/null # Clean up functions -if not is-command brew - functions -e brew-fzf -end -functions -e path-prepend path-append cdpath-append is-command cond-alias \ - alias-diff alias-ls +cleanup |