Adopt the new type -q flag in the other functions

This commit is contained in:
Kevin Ballard 2014-07-10 00:26:58 -07:00
parent 6f7a7459c1
commit 533496e43a
9 changed files with 23 additions and 23 deletions

View file

@ -1,5 +1,5 @@
function __fish_complete_cabal function __fish_complete_cabal
if type -f cabal >/dev/null if type -q -f cabal
set cmd (commandline -poc) set cmd (commandline -poc)
if test (count $cmd) -gt 1 if test (count $cmd) -gt 1
cabal $cmd[2..-1] --list-options cabal $cmd[2..-1] --list-options

View file

@ -2,7 +2,7 @@
function __fish_complete_vi -d "Compleletions for vi and its aliases" --argument-names cmd function __fish_complete_vi -d "Compleletions for vi and its aliases" --argument-names cmd
set -l is_vim set -l is_vim
if type $cmd > /dev/null if type -q $cmd
eval command $cmd --version >/dev/null ^/dev/null; and set -l is_vim vim eval command $cmd --version >/dev/null ^/dev/null; and set -l is_vim vim
end end

View file

@ -248,7 +248,7 @@ function __fish_config_interactive -d "Initializations that should be performed
# First check if we are on OpenSUSE since SUSE's handler has no options # First check if we are on OpenSUSE since SUSE's handler has no options
# and expects first argument to be a command and second database # and expects first argument to be a command and second database
# also check if there is command-not-found command. # also check if there is command-not-found command.
if begin; test -f /etc/SuSE-release; and type -p command-not-found > /dev/null 2> /dev/null; end if begin; test -f /etc/SuSE-release; and type -q -p command-not-found; end
function __fish_command_not_found_handler --on-event fish_command_not_found function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/bin/command-not-found $argv /usr/bin/command-not-found $argv
end end
@ -263,7 +263,7 @@ function __fish_config_interactive -d "Initializations that should be performed
/usr/lib/command-not-found -- $argv /usr/lib/command-not-found -- $argv
end end
# Ubuntu Feisty places this command in the regular path instead # Ubuntu Feisty places this command in the regular path instead
else if type -p command-not-found > /dev/null 2> /dev/null else if type -q -p command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found function __fish_command_not_found_handler --on-event fish_command_not_found
command-not-found -- $argv command-not-found -- $argv
end end

View file

@ -18,7 +18,7 @@ function __fish_print_packages
end end
mkdir -m 700 -p $XDG_CACHE_HOME mkdir -m 700 -p $XDG_CACHE_HOME
if type -f apt-cache >/dev/null if type -q -f apt-cache
# Do not generate the cache as apparently sometimes this is slow. # Do not generate the cache as apparently sometimes this is slow.
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=547550 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=547550
apt-cache --no-generate pkgnames (commandline -tc) ^/dev/null | sed -e 's/$/'\t$package'/' apt-cache --no-generate pkgnames (commandline -tc) ^/dev/null | sed -e 's/$/'\t$package'/'
@ -28,7 +28,7 @@ function __fish_print_packages
# Pkg is fast on FreeBSD and provides versioning info which we want for # Pkg is fast on FreeBSD and provides versioning info which we want for
# installed packages # installed packages
if begin if begin
type -f pkg > /dev/null type -q -f pkg
and test (uname) = "FreeBSD" and test (uname) = "FreeBSD"
end end
pkg query "%n-%v" pkg query "%n-%v"
@ -36,7 +36,7 @@ function __fish_print_packages
end end
# Caches for 5 minutes # Caches for 5 minutes
if type -f pacman >/dev/null if type -q -f pacman
set cache_file $XDG_CACHE_HOME/.pac-cache.$USER set cache_file $XDG_CACHE_HOME/.pac-cache.$USER
if test -f $cache_file if test -f $cache_file
cat $cache_file cat $cache_file
@ -53,7 +53,7 @@ function __fish_print_packages
end end
# yum is slow, just like rpm, so go to the background # yum is slow, just like rpm, so go to the background
if type -f /usr/share/yum-cli/completion-helper.py >/dev/null if type -q -f /usr/share/yum-cli/completion-helper.py
# If the cache is less than six hours old, we do not recalculate it # If the cache is less than six hours old, we do not recalculate it
@ -75,7 +75,7 @@ function __fish_print_packages
# Rpm is too slow for this job, so we set it up to do completions # Rpm is too slow for this job, so we set it up to do completions
# as a background job and cache the results. # as a background job and cache the results.
if type -f rpm >/dev/null if type -q -f rpm
# If the cache is less than five minutes old, we do not recalculate it # If the cache is less than five minutes old, we do not recalculate it
@ -99,12 +99,12 @@ function __fish_print_packages
# installed on the system packages is in completions/emerge.fish # installed on the system packages is in completions/emerge.fish
# eix is MUCH faster than emerge so use it if it is available # eix is MUCH faster than emerge so use it if it is available
if type -f eix > /dev/null if type -q -f eix
eix --only-names "^"(commandline -tc) | cut -d/ -f2 eix --only-names "^"(commandline -tc) | cut -d/ -f2
return return
else else
# FIXME? Seems to be broken # FIXME? Seems to be broken
if type -f emerge >/dev/null if type -q -f emerge
emerge -s \^(commandline -tc) |sgrep "^*" |cut -d\ -f3 |cut -d/ -f2 emerge -s \^(commandline -tc) |sgrep "^*" |cut -d\ -f3 |cut -d/ -f2
return return
end end

View file

@ -51,7 +51,7 @@ function funced --description 'Edit function definition'
if test -n "$editor" if test -n "$editor"
set -l editor_cmd set -l editor_cmd
eval set editor_cmd $editor eval set editor_cmd $editor
if not type -f "$editor_cmd[1]" >/dev/null if not type -q -f "$editor_cmd[1]"
_ "funced: The value for \$EDITOR '$editor' could not be used because the command '$editor_cmd[1]' could not be found _ "funced: The value for \$EDITOR '$editor' could not be used because the command '$editor_cmd[1]' could not be found
" "
set editor fish set editor fish

View file

@ -25,7 +25,7 @@ function help --description 'Show help for the fish shell'
set -l graphical_browsers htmlview x-www-browser firefox galeon mozilla konqueror epiphany opera netscape rekonq google-chrome chromium-browser set -l graphical_browsers htmlview x-www-browser firefox galeon mozilla konqueror epiphany opera netscape rekonq google-chrome chromium-browser
set -l text_browsers htmlview www-browser links elinks lynx w3m set -l text_browsers htmlview www-browser links elinks lynx w3m
if type "$BROWSER" >/dev/null if type -q "$BROWSER"
# User has manually set a preferred browser, so we respect that # User has manually set a preferred browser, so we respect that
set fish_browser $BROWSER set fish_browser $BROWSER
@ -36,7 +36,7 @@ function help --description 'Show help for the fish shell'
else else
# Check for a text-based browser. # Check for a text-based browser.
for i in $text_browsers for i in $text_browsers
if type -f $i >/dev/null if type -q -f $i
set fish_browser $i set fish_browser $i
break break
end end
@ -46,7 +46,7 @@ function help --description 'Show help for the fish shell'
# browser to use instead. # browser to use instead.
if test "$DISPLAY" -a \( "$XAUTHORITY" = "$HOME/.Xauthority" -o "$XAUTHORITY" = "" \) if test "$DISPLAY" -a \( "$XAUTHORITY" = "$HOME/.Xauthority" -o "$XAUTHORITY" = "" \)
for i in $graphical_browsers for i in $graphical_browsers
if type -f $i >/dev/null if type -q -f $i
set fish_browser $i set fish_browser $i
set fish_browser_bg 1 set fish_browser_bg 1
break break
@ -55,17 +55,17 @@ function help --description 'Show help for the fish shell'
end end
# If the OS appears to be Windows (graphical), try to use cygstart # If the OS appears to be Windows (graphical), try to use cygstart
if type cygstart > /dev/null if type -q cygstart
set fish_browser cygstart set fish_browser cygstart
# If xdg-open is available, just use that # If xdg-open is available, just use that
else if type xdg-open > /dev/null else if type -q xdg-open
set fish_browser xdg-open set fish_browser xdg-open
end end
# On OS X, we go through osascript by default # On OS X, we go through osascript by default
if test (uname) = Darwin if test (uname) = Darwin
if type osascript >/dev/null if type -q osascript
set fish_browser osascript set fish_browser osascript
end end
end end
@ -92,7 +92,7 @@ function help --description 'Show help for the fish shell'
case $help_topics case $help_topics
set fish_help_page "index.html\#$fish_help_item" set fish_help_page "index.html\#$fish_help_item"
case "*" case "*"
if type -f $fish_help_item >/dev/null if type -q -f $fish_help_item
# Prefer to use fish's man pages, to avoid # Prefer to use fish's man pages, to avoid
# the annoying useless "builtin" man page bash # the annoying useless "builtin" man page bash
# installs on OS X # installs on OS X

View file

@ -13,7 +13,7 @@ if command ls --version 1>/dev/null 2>/dev/null
end end
if not set -q LS_COLORS if not set -q LS_COLORS
if type -f dircolors >/dev/null if type -q -f dircolors
eval (dircolors -c | sed 's/>&\/dev\/null$//') eval (dircolors -c | sed 's/>&\/dev\/null$//')
end end
end end

View file

@ -14,11 +14,11 @@ if not test (uname) = Darwin
end end
end end
if type -f cygstart >/dev/null if type -q -f cygstart
for i in $argv for i in $argv
cygstart $i cygstart $i
end end
else if type -f xdg-open >/dev/null else if type -q -f xdg-open
for i in $argv for i in $argv
xdg-open $i xdg-open $i
end end

View file

@ -2,7 +2,7 @@
# test -x in /usr/bin/seq because that's where it usually is and # test -x in /usr/bin/seq because that's where it usually is and
# that's substantially cheaper than the type function # that's substantially cheaper than the type function
if begin ; not test -x /usr/bin/seq ; and not type -f seq > /dev/null; end if begin ; not test -x /usr/bin/seq ; and not type -q -f seq; end
# 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