mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +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,
|
# with weird output on stdout (!). But before the function is called, no npm command is defined,
|
||||||
# so calling the command would fail.
|
# so calling the command would fail.
|
||||||
# So we'll only try if we have an npm command.
|
# 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
|
# 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
|
# COMP_LINE is an array with the words in the commandline
|
||||||
set -lx COMP_LINE (commandline -o)
|
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
|
# list available npm scripts and their parial content
|
||||||
function __fish_npm_run
|
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.
|
# 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
|
command npm run | string match -r -v '^[^ ]|^$' | string trim | while read -l name
|
||||||
set -l trim 20
|
set -l trim 20
|
||||||
read -l value
|
read -l value
|
||||||
|
|
|
@ -28,7 +28,7 @@ function __fish_rbenv_installed_rubies
|
||||||
end
|
end
|
||||||
|
|
||||||
function __fish_rbenv_official_rubies
|
function __fish_rbenv_official_rubies
|
||||||
if command -s ruby-build >/dev/null
|
if command -sq ruby-build
|
||||||
ruby-build --definitions
|
ruby-build --definitions
|
||||||
else
|
else
|
||||||
# Remove trailing spaces, otherwise completion options appear like
|
# Remove trailing spaces, otherwise completion options appear like
|
||||||
|
|
|
@ -268,7 +268,7 @@ if status --is-login
|
||||||
|
|
||||||
if test "$TERM" = linux
|
if test "$TERM" = linux
|
||||||
if string match -qir '\.UTF' -- $LANG
|
if string match -qir '\.UTF' -- $LANG
|
||||||
if command -s unicode_start >/dev/null
|
if command -sq unicode_start
|
||||||
unicode_start
|
unicode_start
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# Alias for gettext or a fallback if gettext isn't installed.
|
# 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"
|
function _ --description "Alias for the gettext command"
|
||||||
command gettext fish $argv
|
command gettext fish $argv
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
function __fish_complete_groups --description "Print a list of local groups, with group members as the description"
|
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/'
|
getent group | cut -d ':' -f 1,4 | sed 's/:/\t/'
|
||||||
else
|
else
|
||||||
cut -d ':' -f 1,4 /etc/group | sed 's/:/\t/'
|
cut -d ':' -f 1,4 /etc/group | sed 's/:/\t/'
|
||||||
|
|
|
@ -330,7 +330,7 @@ end
|
||||||
function __fish_git_prompt --description "Prompt function for Git"
|
function __fish_git_prompt --description "Prompt function for Git"
|
||||||
# If git isn't installed, there's nothing we can do
|
# If git isn't installed, there's nothing we can do
|
||||||
# Return 1 so the calling prompt can deal with it
|
# Return 1 so the calling prompt can deal with it
|
||||||
if not command -s git >/dev/null
|
if not command -sq git
|
||||||
return 1
|
return 1
|
||||||
end
|
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)
|
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'
|
function __fish_hg_prompt --description 'Write out the hg prompt'
|
||||||
# If hg isn't installed, there's nothing we can do
|
# If hg isn't installed, there's nothing we can do
|
||||||
# Return 1 so the calling prompt can deal with it
|
# Return 1 so the calling prompt can deal with it
|
||||||
if not command -s hg >/dev/null
|
if not command -sq hg
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
function __fish_print_addresses --description "Print a list of known network addresses"
|
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:"
|
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
|
# This is for OSX/BSD
|
||||||
# There's also linux ifconfig but that has at least two different output formats
|
# There's also linux ifconfig but that has at least two different output formats
|
||||||
# is basically dead, and ip is installed on everything now
|
# is basically dead, and ip is installed on everything now
|
||||||
|
|
|
@ -91,7 +91,7 @@ end
|
||||||
|
|
||||||
function __fish_svn_prompt --description "Prompt function for svn"
|
function __fish_svn_prompt --description "Prompt function for svn"
|
||||||
# if svn isn't installed then don't do anything
|
# if svn isn't installed then don't do anything
|
||||||
if not command -s svn >/dev/null
|
if not command -sq svn
|
||||||
return 1
|
return 1
|
||||||
end
|
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'
|
function __terlar_git_prompt --description 'Write out the git prompt'
|
||||||
# If git isn't installed, there's nothing we can do
|
# If git isn't installed, there's nothing we can do
|
||||||
# Return 1 so the calling prompt can deal with it
|
# Return 1 so the calling prompt can deal with it
|
||||||
if not command -s git >/dev/null
|
if not command -sq git
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
set -l branch (git rev-parse --abbrev-ref HEAD ^/dev/null)
|
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
|
# check if command fish_indent works and is the same version that
|
||||||
# came with this fish. This will happen one time.
|
# 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
|
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".
|
# if alias doesn't define the function here, this is an autoloaded "nothing".
|
||||||
# the command (if there is one) will be used by default.
|
# 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
|
# check if command fish_key_reader works and is the same version that
|
||||||
# came with this fish. This will happen one time.
|
# 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
|
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".
|
# if alias doesn't define the function here, this is an autoloaded "nothing".
|
||||||
# the command (if there is one) will be used by default.
|
# the command (if there is one) will be used by default.
|
||||||
|
|
|
@ -12,7 +12,7 @@ if command ls --version >/dev/null ^/dev/null
|
||||||
end
|
end
|
||||||
|
|
||||||
if not set -q LS_COLORS
|
if not set -q LS_COLORS
|
||||||
if command -s dircolors >/dev/null
|
if command -sq dircolors
|
||||||
set -l colorfile
|
set -l colorfile
|
||||||
for file in ~/.dir_colors ~/.dircolors /etc/DIR_COLORS
|
for file in ~/.dir_colors ~/.dircolors /etc/DIR_COLORS
|
||||||
if test -f $file
|
if test -f $file
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# application for the file.
|
# application for the file.
|
||||||
#
|
#
|
||||||
|
|
||||||
if not command -s open >/dev/null
|
if not command -sq open
|
||||||
function open --description "Open file in default application"
|
function open --description "Open file in default application"
|
||||||
if count $argv >/dev/null
|
if count $argv >/dev/null
|
||||||
switch $argv[1]
|
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.
|
# 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.
|
# 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]"
|
function realpath -w realpath -d "print the resolved path [command realpath]"
|
||||||
command realpath $argv
|
command realpath $argv
|
||||||
end
|
end
|
||||||
|
@ -14,7 +14,7 @@ if command -s realpath >/dev/null
|
||||||
end
|
end
|
||||||
|
|
||||||
# If there is a HomeBrew installed version of GNU realpath named grealpath use that.
|
# 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]"
|
function realpath -w grealpath -d "print the resolved path [command grealpath]"
|
||||||
command grealpath $argv
|
command grealpath $argv
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# If seq is not installed, then define a function that invokes __fish_fallback_seq
|
# 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
|
# 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
|
# No seq command
|
||||||
function seq --description "Print sequences of numbers"
|
function seq --description "Print sequences of numbers"
|
||||||
__fish_fallback_seq $argv
|
__fish_fallback_seq $argv
|
||||||
|
|
Loading…
Reference in a new issue