diff --git a/share/functions/__fish_describe_command.fish b/share/functions/__fish_describe_command.fish index d850a6152..7fb334d78 100644 --- a/share/functions/__fish_describe_command.fish +++ b/share/functions/__fish_describe_command.fish @@ -8,8 +8,7 @@ function __fish_describe_command -d "Command used to find descriptions for comma # TODO: stop interpolating argv into regex, and remove this hack. string match --quiet --regex '^[a-zA-Z0-9_ ]+$' -- "$argv" or return - type -q apropos - or return + type -q apropos; or return apropos $argv 2>/dev/null | awk -v FS=" +- +" '{ split($1, names, ", "); for (name in names) diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish index ef95b7470..0d74aa084 100644 --- a/share/functions/__fish_print_help.fish +++ b/share/functions/__fish_print_help.fish @@ -73,23 +73,18 @@ function __fish_print_help --description "Print help message for the specified f # Remove man's bolding set -l name (string replace -ra '(.)'\b'.' '$1' -- $line) # We start after we have the name - contains -- $name NAME - and set have_name 1 - and continue + contains -- $name NAME; and set have_name 1; and continue # We ignore the SYNOPSIS header - contains -- $name SYNOPSIS - and continue + contains -- $name SYNOPSIS; and continue # Everything after COPYRIGHT is useless - contains -- $name COPYRIGHT - and break + contains -- $name COPYRIGHT; and break # not leading space, and not empty, so must contain a non-space # in the first column. That makes it a header/footer. set line_type meta end - set -q have_name[1] - or continue + set -q have_name[1]; or continue switch $state case normal switch $line_type diff --git a/share/functions/__fish_print_packages.fish b/share/functions/__fish_print_packages.fish index 8ed0a9a2e..320192473 100644 --- a/share/functions/__fish_print_packages.fish +++ b/share/functions/__fish_print_packages.fish @@ -3,7 +3,6 @@ function __fish_print_packages argparse --name=__fish_print_packages 'i/installed' -- $argv or return - set -l only_installed 1 if not set -q _flag_installed set -e only_installed diff --git a/share/functions/_fish_systemctl.fish b/share/functions/_fish_systemctl.fish index 2fea85e58..669bd41e5 100644 --- a/share/functions/_fish_systemctl.fish +++ b/share/functions/_fish_systemctl.fish @@ -33,30 +33,23 @@ function _fish_systemctl --description 'Call systemctl with some options from th help reset-failed list-dependencies list-units revert add-{wants,requires} edit case enable # This will only work for "list-unit-files", but won't print an error for "list-units". - set -q _flag_state - or set _flag_state disabled + set -q _flag_state; or set _flag_state disabled case disable - set -q _flag_state - or set _flag_state enabled + set -q _flag_state; or set _flag_state enabled case start # Running `start` on an already started unit isn't an _error_, but useless. - set -q _flag_state - or set _flag_state dead,failed + set -q _flag_state; or set _flag_state dead,failed case mask - set -q _flag_state - or set _flag_state loaded + set -q _flag_state; or set _flag_state loaded case unmask - set -q _flag_state - or set _flag_state masked + set -q _flag_state; or set _flag_state masked case stop kill # TODO: Is "kill" useful on other unit types? # Running as the catch-all, "mounted" for .mount units, "active" for .target. - set -q _flag_state - or set _flag_state running,mounted,active + set -q _flag_state; or set _flag_state running,mounted,active case isolate set-default # These only take one unit. - set -q argv[1] - and return + set -q argv[1]; and return case list-sockets set _flag_type socket case list-timers @@ -72,16 +65,11 @@ function _fish_systemctl --description 'Call systemctl with some options from th end # Add the flags back so we can pass them to our systemctl invocations. - set -q _flag_type - and set passflags $passflags --type=$_flag_type - set -q _flag_state - and set passflags $passflags --state=$_flag_state - set -q _flag_property - and set passflags $passflags --property=$_flag_property - set -q _flag_machine - and set passflags $passflags --machine=$_flag_machine - set -q _flag_host - and set passflags $passflags --host=$_flag_host + set -q _flag_type; and set passflags $passflags --type=$_flag_type + set -q _flag_state; and set passflags $passflags --state=$_flag_state + set -q _flag_property; and set passflags $passflags --property=$_flag_property + set -q _flag_machine; and set passflags $passflags --machine=$_flag_machine + set -q _flag_host; and set passflags $passflags --host=$_flag_host # Output looks like # systemd-tmpfiles-clean.timer [more whitespace] loaded active waiting Daily Cleanup[...] diff --git a/share/functions/abbr.fish b/share/functions/abbr.fish index e37c1557b..b328c5120 100644 --- a/share/functions/abbr.fish +++ b/share/functions/abbr.fish @@ -53,14 +53,12 @@ function abbr --description "Manage abbreviations" else if set -q _flag_query[1] # "--query": Check if abbrs exist. # If we don't have an argument, it's an automatic failure. - set -q argv[1] - or return 1 + set -q argv[1]; or return 1 set -l escaped _fish_abbr_(string escape --style=var -- $argv) # We return 0 if any arg exists, whereas `set -q` returns the number of undefined arguments. # But we should be consistent with `type -q` and `command -q`. for var in $escaped - set -q $escaped - and return 0 + set -q $escaped; and return 0 end return 1 else diff --git a/share/functions/fish_clipboard_copy.fish b/share/functions/fish_clipboard_copy.fish index 088c9c921..0054198aa 100644 --- a/share/functions/fish_clipboard_copy.fish +++ b/share/functions/fish_clipboard_copy.fish @@ -1,8 +1,7 @@ function fish_clipboard_copy # Copy the current selection, or the entire commandline if that is empty. set -l cmdline (commandline --current-selection) - test -n "$cmdline" - or set cmdline (commandline) + test -n "$cmdline"; or set cmdline (commandline) if type -q pbcopy printf '%s\n' $cmdline | pbcopy else if type -q xsel diff --git a/share/functions/fish_git_prompt.fish b/share/functions/fish_git_prompt.fish index eef67866a..cf3623bfa 100644 --- a/share/functions/fish_git_prompt.fish +++ b/share/functions/fish_git_prompt.fish @@ -454,8 +454,7 @@ function fish_git_prompt --description "Prompt function for Git" set b (string replace refs/heads/ '' -- $b) set -q __fish_git_prompt_shorten_branch_char_suffix or set -l __fish_git_prompt_shorten_branch_char_suffix "…" - if string match -qr '^\d+$' "$__fish_git_prompt_shorten_branch_len" - and test (string length "$b") -gt $__fish_git_prompt_shorten_branch_len + if string match -qr '^\d+$' "$__fish_git_prompt_shorten_branch_len"; and test (string length "$b") -gt $__fish_git_prompt_shorten_branch_len set b (string sub -l "$__fish_git_prompt_shorten_branch_len" "$b")"$__fish_git_prompt_shorten_branch_char_suffix" end if test -n "$b" @@ -549,8 +548,7 @@ function __fish_git_prompt_informative_status set -l untrackedfiles (command git ls-files --others --exclude-standard | count) set -l stashstate 0 set -l stashfile "$argv[1]/logs/refs/stash" - if set -q __fish_git_prompt_showstashstate - and test -e "$stashfile" + if set -q __fish_git_prompt_showstashstate; and test -e "$stashfile" set stashstate (count < $stashfile) end diff --git a/share/functions/help.fish b/share/functions/help.fish index 56210688f..bfbcc4443 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -69,8 +69,7 @@ function help --description 'Show help for the fish shell' set fish_browser cygstart # If xdg-open is available, just use that # but only if an X session is running - else if type -q xdg-open - and set -q -x DISPLAY + else if type -q xdg-open; and set -q -x DISPLAY set fish_browser xdg-open end diff --git a/share/functions/type.fish b/share/functions/type.fish index ba2b81dd4..66df5ee6b 100644 --- a/share/functions/type.fish +++ b/share/functions/type.fish @@ -62,7 +62,6 @@ function type --description 'Print the type of a command' case "n/a" case "stdin" break - case "*" echo $func_path end