mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
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:
parent
40de253b3a
commit
0a8c922d92
16 changed files with 19 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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/'
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue