Use command -sq instead of redirection

This option has been available for a while now and it's a bit shorter.
This commit is contained in:
Fabian Homborg 2017-02-13 17:30:38 +01:00
parent 40de253b3a
commit 0a8c922d92
16 changed files with 19 additions and 19 deletions

View file

@ -44,7 +44,7 @@ function __fish_complete_npm --description "Complete the commandline using npm's
# with weird output on stdout (!). But before the function is called, no npm command is defined,
# so calling the command would fail.
# So we'll only try if we have an npm command.
if command -s npm >/dev/null
if command -sq npm
# npm completion is bash-centric, so we need to translate fish's "commandline" stuff to bash's $COMP_* stuff
# COMP_LINE is an array with the words in the commandline
set -lx COMP_LINE (commandline -o)
@ -72,7 +72,7 @@ complete -f -c npm -n 'not __fish_npm_needs_option' -a "(__fish_complete_npm)"
# list available npm scripts and their parial content
function __fish_npm_run
# Like above, only try to call npm if there's a command by that name to facilitate aliases that call nvm.
if command -s npm >/dev/null
if command -sq npm
command npm run | string match -r -v '^[^ ]|^$' | string trim | while read -l name
set -l trim 20
read -l value

View file

@ -28,7 +28,7 @@ function __fish_rbenv_installed_rubies
end
function __fish_rbenv_official_rubies
if command -s ruby-build >/dev/null
if command -sq ruby-build
ruby-build --definitions
else
# Remove trailing spaces, otherwise completion options appear like

View file

@ -268,7 +268,7 @@ if status --is-login
if test "$TERM" = linux
if string match -qir '\.UTF' -- $LANG
if command -s unicode_start >/dev/null
if command -sq unicode_start
unicode_start
end
end

View file

@ -1,7 +1,7 @@
#
# Alias for gettext or a fallback if gettext isn't installed.
#
if command -s gettext >/dev/null
if command -sq gettext
function _ --description "Alias for the gettext command"
command gettext fish $argv
end

View file

@ -1,6 +1,6 @@
function __fish_complete_groups --description "Print a list of local groups, with group members as the description"
if command -s getent >/dev/null
if command -sq getent
getent group | cut -d ':' -f 1,4 | sed 's/:/\t/'
else
cut -d ':' -f 1,4 /etc/group | sed 's/:/\t/'

View file

@ -330,7 +330,7 @@ end
function __fish_git_prompt --description "Prompt function for Git"
# If git isn't installed, there's nothing we can do
# Return 1 so the calling prompt can deal with it
if not command -s git >/dev/null
if not command -sq git
return 1
end
set -l repo_info (command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD ^/dev/null)

View file

@ -23,7 +23,7 @@ set -g fish_prompt_hg_status_order added modified copied deleted untracked unmer
function __fish_hg_prompt --description 'Write out the hg prompt'
# If hg isn't installed, there's nothing we can do
# Return 1 so the calling prompt can deal with it
if not command -s hg >/dev/null
if not command -sq hg
return 1
end

View file

@ -1,7 +1,7 @@
function __fish_print_addresses --description "Print a list of known network addresses"
if command -s ip >/dev/null
if command -sq ip
command ip --oneline address | cut -d" " -f7 | sed "s:\(.*\)/.*:\1:"
else if command -s ifconfig >/dev/null
else if command -sq ifconfig
# This is for OSX/BSD
# There's also linux ifconfig but that has at least two different output formats
# is basically dead, and ip is installed on everything now

View file

@ -91,7 +91,7 @@ end
function __fish_svn_prompt --description "Prompt function for svn"
# if svn isn't installed then don't do anything
if not command -s svn >/dev/null
if not command -sq svn
return 1
end

View file

@ -23,7 +23,7 @@ set -g fish_prompt_git_status_order added modified renamed copied deleted untrac
function __terlar_git_prompt --description 'Write out the git prompt'
# If git isn't installed, there's nothing we can do
# Return 1 so the calling prompt can deal with it
if not command -s git >/dev/null
if not command -sq git
return 1
end
set -l branch (git rev-parse --abbrev-ref HEAD ^/dev/null)

View file

@ -1,6 +1,6 @@
# check if command fish_indent works and is the same version that
# came with this fish. This will happen one time.
command -s fish_indent >/dev/null
command -sq fish_indent
and command fish_indent --version 2>&1 | string match -rq $FISH_VERSION
# if alias doesn't define the function here, this is an autoloaded "nothing".
# the command (if there is one) will be used by default.

View file

@ -1,6 +1,6 @@
# check if command fish_key_reader works and is the same version that
# came with this fish. This will happen one time.
command -s fish_key_reader >/dev/null
command -sq fish_key_reader
and command fish_key_reader --version 2>&1 | string match -rq $FISH_VERSION
# if alias doesn't define the function here, this is an autoloaded "nothing".
# the command (if there is one) will be used by default.

View file

@ -12,7 +12,7 @@ if command ls --version >/dev/null ^/dev/null
end
if not set -q LS_COLORS
if command -s dircolors >/dev/null
if command -sq dircolors
set -l colorfile
for file in ~/.dir_colors ~/.dircolors /etc/DIR_COLORS
if test -f $file

View file

@ -3,7 +3,7 @@
# application for the file.
#
if not command -s open >/dev/null
if not command -sq open
function open --description "Open file in default application"
if count $argv >/dev/null
switch $argv[1]

View file

@ -6,7 +6,7 @@
# external command by that name. That's because if we don't the parser will select our builtin.
# However, we only want our builtin if there is no external realpath command.
if command -s realpath >/dev/null
if command -sq realpath
function realpath -w realpath -d "print the resolved path [command realpath]"
command realpath $argv
end
@ -14,7 +14,7 @@ if command -s realpath >/dev/null
end
# If there is a HomeBrew installed version of GNU realpath named grealpath use that.
if command -s grealpath >/dev/null
if command -sq grealpath
function realpath -w grealpath -d "print the resolved path [command grealpath]"
command grealpath $argv
end

View file

@ -1,7 +1,7 @@
# If seq is not installed, then define a function that invokes __fish_fallback_seq
# We can't call type here because that also calls seq
if not command -s seq >/dev/null
if not command -sq seq
# No seq command
function seq --description "Print sequences of numbers"
__fish_fallback_seq $argv