reformat all fish scripts

I hate doing this but I am tired of touching a fish script as part of
some change and having `make style` radically change it. Which makes
editing fish scripts more painful than it needs to be. It is time to do
a wholesale reformatting of these scripts to conform to the documented
style as implemented by the `fish_indent` program.
This commit is contained in:
Kurtis Rader 2016-11-27 21:27:22 -08:00
parent 54a76bb9e5
commit 11a60c8374
161 changed files with 2638 additions and 2587 deletions

View file

@ -1,14 +1,14 @@
function __fish_bind_test2
set -l args
for i in (commandline -poc)
set -l args
for i in (commandline -poc)
switch $i
case "-*"
case "*"
set args $args $i
end
end
end
switch (count $args)
case 2

View file

@ -8,7 +8,8 @@ function __fish_complete_ant_targets -d "Print list of targets from build.xml an
set files (sed -n "s/^.*<import[^>]* file=[\"']\([^\"']*\)[\"'].*\$/\1/p" < $buildfile)
# iterate through files and display their targets
for file in $files;
for file in $files
__fish_filter_ant_targets $file
end
end

View file

@ -4,11 +4,13 @@ function __fish_complete_cd -d "Completions for the cd command"
if string match -qr '^\.?\.?/.*' -- $token
for d in $token*/
# Check if it's accessible - the glob only matches directories
[ -x $d ]; and printf "%s\n" $d
[ -x $d ]
and printf "%s\n" $d
end
else # Relative path - check $CDPATH and use that as description
set -l cdpath $CDPATH
[ -z "$cdpath" ]; and set cdpath "."
[ -z "$cdpath" ]
and set cdpath "."
# Remove the real path to "." (i.e. $PWD) from cdpath if we're in it
# so it doesn't get printed in the descriptions
if set -l ind (contains -i -- $PWD $cdpath)
@ -21,11 +23,13 @@ function __fish_complete_cd -d "Completions for the cd command"
set -l desc
# Don't show description for current directory
# and replace $HOME with "~"
[ $i = "." ]; or set -l desc (string replace -r -- "^$HOME" "~" "$i")
[ $i = "." ]
or set -l desc (string replace -r -- "^$HOME" "~" "$i")
# This assumes the CDPATH component itself is cd-able
for d in $i/$token*/
# Remove the cdpath component again
[ -x $d ]; and printf "%s\t%s\n" (string replace -r "^$i/" "" -- $d) $desc
[ -x $d ]
and printf "%s\t%s\n" (string replace -r "^$i/" "" -- $d) $desc
end
end
end

View file

@ -6,7 +6,7 @@ where:
separator - a symbol, separating individual entries
function - a function which prints a completion list to complete each entry
prefix - a prefix, which is printed before the list
itemprefix - a prefix, which is printed before each item" > /dev/stderr
itemprefix - a prefix, which is printed before each item" >/dev/stderr
return 1
end
set -q iprefix[1]

View file

@ -1,3 +1,3 @@
function __fish_complete_lsusb
lsusb | awk '{print $2 ":" $4}'| cut -c1-7
lsusb | awk '{print $2 ":" $4}' | cut -c1-7
end

View file

@ -1,25 +1,25 @@
function __fish_complete_svn_diff --description 'Complete "svn diff" arguments'
set -l cmdl (commandline -cop)
#set -l cmdl svn diff --diff-cmd diff --extensions '-a -b'
set -l diff diff
set -l args
while set -q cmdl[1]
switch $cmdl[1]
case --diff-cmd
if set -q cmdl[2]
set diff $cmdl[2]
set -e cmd[2]
end
#set -l cmdl svn diff --diff-cmd diff --extensions '-a -b'
set -l diff diff
set -l args
while set -q cmdl[1]
switch $cmdl[1]
case --diff-cmd
if set -q cmdl[2]
set diff $cmdl[2]
set -e cmd[2]
end
case --extensions
if set -q cmdl[2]
set args $cmdl[2]
set -e cmdl[2]
end
end
set -e cmdl[1]
end
set -l token (commandline -cpt)
complete -C"$diff $args $token"
case --extensions
if set -q cmdl[2]
set args $cmdl[2]
set -e cmdl[2]
end
end
set -e cmdl[1]
end
set -l token (commandline -cpt)
complete -C"$diff $args $token"
end

View file

@ -5,6 +5,6 @@ function __fish_complete_users --description "Print a list of local users, with
else if test -x /usr/bin/dscl
dscl . -list /Users RealName | string match -r -v '^_' | string replace -r ' {2,}' \t
else
string match -v -r '^\s*#' < /etc/passwd | cut -d : -f 1,5 | string replace ':' \t
string match -v -r '^\s*#' </etc/passwd | cut -d : -f 1,5 | string replace ':' \t
end
end

View file

@ -21,7 +21,7 @@ function __fish_complete_wvdial_peers --description 'Complete wvdial peers' --ar
for file in $cfgfiles
if test -f $file
string match -r '\[Dialer' < $file | string replace -r '\[Dialer (.+)\]' '$1'
string match -r '\[Dialer' <$file | string replace -r '\[Dialer (.+)\]' '$1'
end
end | sort -u | string match -v Defaults

View file

@ -234,7 +234,8 @@ function __fish_config_interactive -d "Initializations that should be performed
# Suppress duplicative title display on Terminal.app
if not functions -q fish_title
echo -n \e\]0\;\a # clear existing title
function fish_title -d 'no-op terminal title'; end
function fish_title -d 'no-op terminal title'
end
end
end
__update_cwd_osc # Run once because we might have already inherited a PWD from an old tab

View file

@ -1,4 +1,4 @@
# a function to obtain a list of installed packages with CRUX pkgutils
function __fish_crux_packages -d 'Obtain a list of installed packages'
pkginfo -i|cut -d' ' -f1
pkginfo -i | cut -d' ' -f1
end

View file

@ -1,3 +1,3 @@
function __fish_filter_ant_targets -d "Display targets within an ant build.xml file"
sed -n "s/^.*<target[^>]* name=[\"']\([^\"']*\)[\"'].*\$/\1/p" < $argv[1]
sed -n "s/^.*<target[^>]* name=[\"']\([^\"']*\)[\"'].*\$/\1/p" <$argv[1]
end

View file

@ -484,7 +484,8 @@ function __fish_git_prompt_informative_status
# If `math` fails for some reason, assume the state is clean - it's the simpler path
set -l state (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles ^/dev/null)
if test -z "$state"; or test "$state" = 0
if test -z "$state"
or test "$state" = 0
set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done
else
for i in $___fish_git_prompt_status_order

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 -s hg >/dev/null
return 1
end
@ -69,12 +69,18 @@ function __fish_hg_prompt --description 'Write out the hg prompt'
# Add a character for each file status if we have one
switch $line
case 'A ' ; set hg_statuses $hg_statuses added
case 'M ' ' M' ; set hg_statuses $hg_statuses modified
case 'C ' ; set hg_statuses $hg_statuses copied
case 'D ' ' D' ; set hg_statuses $hg_statuses deleted
case '\? ' ; set hg_statuses $hg_statuses untracked
case 'U*' '*U' 'DD' 'AA'; set hg_statuses $hg_statuses unmerged
case 'A '
set hg_statuses $hg_statuses added
case 'M ' ' M'
set hg_statuses $hg_statuses modified
case 'C '
set hg_statuses $hg_statuses copied
case 'D ' ' D'
set hg_statuses $hg_statuses deleted
case '\? '
set hg_statuses $hg_statuses untracked
case 'U*' '*U' 'DD' 'AA'
set hg_statuses $hg_statuses unmerged
end
end

View file

@ -7,7 +7,8 @@ function __fish_is_first_token -d 'Test if no non-switch argument has been speci
case '-*'
case '*'
return 1;
return 1
end
end
return 0

View file

@ -11,7 +11,8 @@ function __fish_make_completion_signals --description 'Make list of kill signals
# The procps `kill -L` produces a more compact table. We can distinguish the two cases by
# testing whether it supports `kill -t`; in which case it is the coreutils `kill` command.
# Darwin doesn't have kill -t or kill -L
if kill -t ^/dev/null >/dev/null; or not kill -L ^/dev/null >/dev/null
if kill -t ^/dev/null >/dev/null
or not kill -L ^/dev/null >/dev/null
# Posix systems print out the name of a signal using 'kill -l SIGNUM'.
complete -c kill -s l --description "List names of available signals"
for i in (seq 31)

View file

@ -5,7 +5,7 @@ function __fish_paginate -d "Paginate the current command using the users defaul
set cmd $PAGER
end
if commandline -j| string match -q -r -v "$cmd *\$"
if commandline -j | string match -q -r -v "$cmd *\$"
commandline -aj " ^&1 |$cmd;"
end

View file

@ -1,3 +1,3 @@
function __fish_print_encodings -d "Complete using available character encodings"
iconv --list|sed -e 's|//||'
iconv --list | sed -e 's|//||'
end

View file

@ -1,5 +1,5 @@
function __fish_print_function_prototypes -d "Prints the names of all function prototypes found in the headers in the current directory"
cat *.h*|sed -n "s/^\(.*[^[a-zA-Z_0-9]\|\)\([a-zA-Z_][a-zA-Z_0-9]*\) *(.*);.*\$/\2/p"
cat *.h* | sed -n "s/^\(.*[^[a-zA-Z_0-9]\|\)\([a-zA-Z_][a-zA-Z_0-9]*\) *(.*);.*\$/\2/p"
end

View file

@ -4,38 +4,36 @@ function __fish_print_hostnames -d "Print a list of known hostnames"
# Print all hosts from /etc/hosts
# use 'getent hosts' on OSes that support it (OpenBSD and Cygwin do not)
if type -q getent; and getent hosts > /dev/null 2>&1 # test if 'getent hosts' works and redirect output so errors don't print
if type -q getent
and getent hosts >/dev/null 2>&1 # test if 'getent hosts' works and redirect output so errors don't print
# Ignore zero ips
getent hosts | string match -r -v '^0.0.0.0' \
| string replace -r '[0-9.]*\s*' '' | string split " "
getent hosts | string match -r -v '^0.0.0.0' | string replace -r '[0-9.]*\s*' '' | string split " "
else if test -r /etc/hosts
# Ignore commented lines and functionally empty lines
string match -r -v '^\s*0.0.0.0|^\s*#|^\s*$' < /etc/hosts \
# Strip comments
| string replace -ra '#.*$' '' \
| string replace -r '[0-9.]*\s*' '' | string trim | string replace -ra '\s+' '\n'
end
string match -r -v '^\s*0.0.0.0|^\s*#|^\s*$' </etc/hosts # Strip comments
| string replace -ra '#.*$' '' | string replace -r '[0-9.]*\s*' '' | string trim | string replace -ra '\s+' '\n'
end
# Print nfs servers from /etc/fstab
if test -r /etc/fstab
# Print nfs servers from /etc/fstab
if test -r /etc/fstab
string match -r '^\s*[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3]:|^[a-zA-Z\.]*:' </etc/fstab | string replace -r ':.*' ''
end
end
# Check hosts known to ssh
set -l known_hosts ~/.ssh/known_hosts{,2} /etc/ssh/known_hosts{,2} # Yes, seriously - the default specifies both with and without "2"
for file in /etc/ssh/ssh_config ~/.ssh/config
# Check hosts known to ssh
set -l known_hosts ~/.ssh/known_hosts{,2} /etc/ssh/known_hosts{,2} # Yes, seriously - the default specifies both with and without "2"
for file in /etc/ssh/ssh_config ~/.ssh/config
if test -r $file
# Print hosts from system wide ssh configuration file
# Note the non-capturing group to avoid printing "name"
string match -ri '\s*Host(?:name)?(?:\s+|\s*=\s*)\w.*' < $file | string replace -ri '^\s*Host(?:name)?\s*(\S+)' '$1' \
| string replace -r '\s+' ' ' | string split ' '
string match -ri '\s*Host(?:name)?(?:\s+|\s*=\s*)\w.*' <$file | string replace -ri '^\s*Host(?:name)?\s*(\S+)' '$1' | string replace -r '\s+' ' ' | string split ' '
set known_hosts $known_hosts (string match -ri '^\s*UserKnownHostsFile|^\s*GlobalKnownHostsFile' < $file \
| string replace -ri '.*KnownHostsFile\s*' '')
end
end
for file in $known_hosts
# Ignore hosts that are hashed, commented or have custom ports (like [localhost]:2200)
test -r $file; and string replace -ra '(\S+) .*' '$1' < $file | string match -r '^[^#|[=]+$' | string split ","
end
return 0
end
for file in $known_hosts
# Ignore hosts that are hashed, commented or have custom ports (like [localhost]:2200)
test -r $file
and string replace -ra '(\S+) .*' '$1' <$file | string match -r '^[^#|[=]+$' | string split ","
end
return 0
end

View file

@ -1,4 +1,4 @@
function __fish_print_lpr_options --description 'Print lpr options'
lpoptions -l ^ /dev/null | sed 's+\(.*\)/\(.*\):.*$+\1\t\2+'
lpoptions -l ^/dev/null | sed 's+\(.*\)/\(.*\):.*$+\1\t\2+'
end

View file

@ -1,5 +1,5 @@
function __fish_print_lpr_printers --description 'Print lpr printers'
lpstat -p ^ /dev/null | sed 's/^\S*\s\(\S*\)\s\(.*\)$/\1\t\2/'
lpstat -p ^/dev/null | sed 's/^\S*\s\(\S*\)\s\(.*\)$/\1\t\2/'
end

View file

@ -1,4 +1,4 @@
# Helper function for completions that need to enumerate Linux modules
function __fish_print_modules
find /lib/modules/(uname -r)/{kernel,misc} -type f ^ /dev/null | sed -e 's$/.*/\([^/.]*\).*$\1$'
find /lib/modules/(uname -r)/{kernel,misc} -type f ^/dev/null | sed -e 's$/.*/\([^/.]*\).*$\1$'
end

View file

@ -5,9 +5,8 @@ function __fish_print_mounted --description 'Print mounted devices'
# \011 encodes a tab, \012 encodes a newline and \\ encodes a backslash
# This will probably break on newlines because of our splitting, though
# and tabs because of descriptions
string replace -r '\S+ (\S+) .*' '$1' </etc/mtab | string replace -a "\040" " " \
| string replace -a "\011" \t | string replace -a "\012" \n | string replace -a "\\\\" "\\"
string replace -r '\S+ (\S+) .*' '$1' </etc/mtab | string replace -a "\040" " " | string replace -a "\011" \t | string replace -a "\012" \n | string replace -a "\\\\" "\\"
else
mount | cut -d " " -f 1-3|tr " " \n|sed -e "s/[0-9\.]*:\//\//"| __fish_sgrep "^/"
mount | cut -d " " -f 1-3 | tr " " \n | sed -e "s/[0-9\.]*:\//\//" | __fish_sgrep "^/"
end
end

View file

@ -1,5 +1,5 @@
function __fish_print_ninja_targets
if [ -f build.ninja ]
ninja -t targets 2> /dev/null | string replace -r ':.*' ''
ninja -t targets 2>/dev/null | string replace -r ':.*' ''
end
end

View file

@ -73,7 +73,7 @@ function __fish_print_packages
end
# Remove package version information from output and pipe into cache file
zypper --quiet --non-interactive search --type=package | tail -n +4 | sed -r 's/^. \| ((\w|[-_.])+).*/\1\t'$package'/g' > $cache_file &
zypper --quiet --non-interactive search --type=package | tail -n +4 | sed -r 's/^. \| ((\w|[-_.])+).*/\1\t'$package'/g' >$cache_file &
return
end
@ -115,7 +115,7 @@ function __fish_print_packages
end
# Remove package version information from output and pipe into cache file
rpm -qa |sed -e 's/-[^-]*-[^-]*$/\t'$package'/' >$cache_file &
rpm -qa | sed -e 's/-[^-]*-[^-]*$/\t'$package'/' >$cache_file &
return
end
@ -130,7 +130,7 @@ function __fish_print_packages
else
# FIXME? Seems to be broken
if type -q -f emerge
emerge -s \^(commandline -tc) | __fish_sgrep "^*" |cut -d\ -f3 |cut -d/ -f2
emerge -s \^(commandline -tc) | __fish_sgrep "^*" | cut -d\ -f3 | cut -d/ -f2
return
end
end

View file

@ -1,3 +1,3 @@
function __fish_print_pacman_repos --description "Print the repositories configured for arch's pacman package manager"
string replace -r -a "\[(.+)\]" "\1" < /etc/pacman.conf | string match -r -v "^#|options"
string replace -r -a "\[(.+)\]" "\1" </etc/pacman.conf | string match -r -v "^#|options"
end

View file

@ -5,7 +5,7 @@ function __fish_print_users --description "Print a list of local users"
else if test -x /usr/bin/dscl # OS X support
dscl . -list /Users | string match -r -v '^_'
else
string match -v -r '^\w*#' < /etc/passwd | cut -d : -f 1
string match -v -r '^\w*#' </etc/passwd | cut -d : -f 1
end
end

View file

@ -1,9 +1,9 @@
switch (uname)
case 'CYGWIN_*'
case 'CYGWIN_*'
function __fish_pwd --description "Show current path"
pwd | sed -e 's-^/cygdrive/\(.\)/\?-\u\1:/-'
end
case '*'
case '*'
function __fish_pwd --description "Show current path"
pwd
end

View file

@ -91,13 +91,14 @@ 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 -s svn >/dev/null
return 1
end
# make sure that this is a svn repo
set -l checkout_info (command svn info ^/dev/null)
if [ $status -ne 0 ];
if [ $status -ne 0 ]
return
end
@ -122,7 +123,8 @@ function __fish_svn_prompt --description "Prompt function for svn"
set -l column_status (printf '%s\n' $svn_status_lines | cut -c $col | tr -d ' \n')
# check that the character count is not zero (this would indicate that there are status flags in this column)
if [ (count $column_status) -ne 0 ];
if [ (count $column_status) -ne 0 ]
# we only want to display unique status flags (eg: if there are 5 modified files, the prompt should only show the modified status once)
set -l column_unique_status (echo $column_status | sort | uniq)
# parse the status flags for this column and create the formatting by calling out to the helper function

View file

@ -1,5 +1,7 @@
# Like for running machines, I'm assuming machinectl doesn't allow spaces in image names
# This does not include the special image ".host" since it isn't valid for most operations
function __fish_systemd_machine_images
machinectl --no-legend --no-pager list-images | while read -l a b; echo $a; end
machinectl --no-legend --no-pager list-images | while read -l a b
echo $a
end
end

View file

@ -1,4 +1,6 @@
# It seems machinectl will eliminate spaces from machine names so we don't need to handle that
function __fish_systemd_machines
machinectl --no-legend --no-pager list --all | while read -l a b; echo $a; end
machinectl --no-legend --no-pager list --all | while read -l a b
echo $a
end
end

View file

@ -13,5 +13,6 @@ function __fish_toggle_comment_commandline --description 'Comment/uncomment the
end
set -l cmdlines (printf '%s\n' '#'$cmdlines | string replace -r '^##' '')
commandline -r $cmdlines
string match -q '#*' $cmdlines[1]; and commandline -f execute
string match -q '#*' $cmdlines[1]
and commandline -f execute
end

View file

@ -2,7 +2,11 @@ function __fish_urlencode --description "URL-encode stdin"
set -l join ''
set -l chars
# Set locale to C and IFS to "" in order to split a line into bytes.
while begin; set -lx LC_ALL C; set -lx IFS ''; read -az chars; end
while begin
set -lx LC_ALL C
set -lx IFS ''
read -az chars
end
printf '%s' $join
# chomp off a trailing newline
if test "$chars[-1]" = \n

View file

@ -51,13 +51,20 @@ function __terlar_git_prompt --description 'Write out the git prompt'
end
switch $i
case 'A ' ; set gs $gs added
case 'M ' ' M' ; set gs $gs modified
case 'R ' ; set gs $gs renamed
case 'C ' ; set gs $gs copied
case 'D ' ' D' ; set gs $gs deleted
case '\?\?' ; set gs $gs untracked
case 'U*' '*U' 'DD' 'AA'; set gs $gs unmerged
case 'A '
set gs $gs added
case 'M ' ' M'
set gs $gs modified
case 'R '
set gs $gs renamed
case 'C '
set gs $gs copied
case 'D ' ' D'
set gs $gs deleted
case '\?\?'
set gs $gs untracked
case 'U*' '*U' 'DD' 'AA'
set gs $gs unmerged
end
end

View file

@ -74,12 +74,14 @@ function abbr --description "Manage abbreviations"
case 'add'
# Convert from old "key=value" syntax
# TODO: This should be removed later
if not set -q mode_arg[2]; and string match -qr '^[^ ]+=' -- $mode_arg
if not set -q mode_arg[2]
and string match -qr '^[^ ]+=' -- $mode_arg
set mode_arg (string split "=" -- $mode_arg)
end
# Bail out early if the exact abbr is already in
contains -- "$mode_arg" $fish_user_abbreviations; and return 0
contains -- "$mode_arg" $fish_user_abbreviations
and return 0
set -l key $mode_arg[1]
set -e mode_arg[1]
set -l value "$mode_arg"
@ -122,7 +124,8 @@ function abbr --description "Manage abbreviations"
# Check to see if either key or value has a leading dash
# If so, we need to write --
string match -q -- '-*' $key $value; and set opt_double_dash '--'
string match -q -- '-*' $key $value
and set opt_double_dash '--'
echo abbr $opt_double_dash (string escape -- $key $value)
end
return 0

View file

@ -1,5 +1,5 @@
function alias --description 'Creates a function wrapping a command'
if count $argv > /dev/null
if count $argv >/dev/null
switch $argv[1]
case -h --h --he --hel --help
__fish_print_help alias

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 -s fish_indent >/dev/null
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 -s fish_key_reader >/dev/null
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

@ -16,7 +16,7 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes'
# We use the `tput` here just to see if terminfo thinks we can change the cursor.
# We cannot use that sequence directly as it's not the correct one for konsole and iTerm,
# and because we may want to change the cursor even though terminfo says we can't (tmux).
if not tput Ss > /dev/null ^/dev/null
if not tput Ss >/dev/null ^/dev/null
# Whitelist tmux...
and not begin
set -q TMUX

View file

@ -69,7 +69,10 @@ function funced --description 'Edit function definition'
set editor fish
end
if begin; set -q interactive[1]; or test "$editor" = fish; end
if begin
set -q interactive[1]
or test "$editor" = fish
end
set -l IFS
if functions -q -- $funcname
# Shadow IFS here to avoid array splitting in command substitution
@ -89,14 +92,15 @@ function funced --description 'Edit function definition'
# OSX mktemp is rather restricted - no suffix, no way to automatically use TMPDIR
# Create a directory so we can use a ".fish" suffix for the file - makes editors pick up that it's a fish file
set -q TMPDIR; or set -l TMPDIR /tmp
set -q TMPDIR
or set -l TMPDIR /tmp
set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX)
set -l tmpname $tmpdir/$funcname.fish
if functions -q -- $funcname
functions -- $funcname > $tmpname
functions -- $funcname >$tmpname
else
echo $init > $tmpname
echo $init >$tmpname
end
# Repeatedly edit until it either parses successfully, or the user cancels
# If the editor command itself fails, we assume the user cancelled or the file

View file

@ -31,7 +31,7 @@ function funcsave --description "Save the current definition of all specified fu
for i in $argv
if functions -q -- $i
functions -- $i > $configdir/fish/functions/$i.fish
functions -- $i >$configdir/fish/functions/$i.fish
else
printf (_ "%s: Unknown function '%s'\n") funcsave $i
set res 1

View file

@ -1,7 +1,7 @@
# Query for USERDOMAIN to shorten waiting times when OS isn't Windows.
set -q USERDOMAIN
and switch (uname)
case 'CYGWIN_*'
case 'CYGWIN_*'
# Cygwin's hostname is broken when computer name contains Unicode
# characters. This hack "fixes" hostname in Cygwin.
function hostname --description "Show or set the system's host name"

View file

@ -7,7 +7,8 @@ function man --description "Format and display the on-line manual pages"
# Notice local but exported variable
set -lx MANPATH (string join : $MANPATH)
if test -z "$MANPATH"
type -q manpath; and set MANPATH (command manpath)
type -q manpath
and set MANPATH (command manpath)
end
set -l fish_manpath (dirname $__fish_datadir)/fish/man
if test -d "$fish_manpath" -a -n "$MANPATH"

View file

@ -12,7 +12,7 @@ function nextd --description "Move forward in the directory history"
# Parse arguments
set -l show_hist 0
set -l times 1
if count $argv > /dev/null
if count $argv >/dev/null
for i in (seq (count $argv))
switch $argv[$i]
case '-l' --l --li --lis --list
@ -35,10 +35,11 @@ function nextd --description "Move forward in the directory history"
# Traverse history
set -l code 1
if count $times > /dev/null
if count $times >/dev/null
for i in (seq $times)
# Try one step backward
if __fish_move_last dirnext dirprev;
if __fish_move_last dirnext dirprev
# We consider it a success if we were able to do at least 1 step
# (low expectations are the key to happiness ;)
set code 0

View file

@ -12,7 +12,7 @@ function prevd --description "Move back in the directory history"
# Parse arguments
set -l show_hist 0
set -l times 1
if count $argv > /dev/null
if count $argv >/dev/null
for i in (seq (count $argv))
switch $argv[$i]
case '-l' --l --li --lis --list
@ -35,10 +35,11 @@ function prevd --description "Move back in the directory history"
# Traverse history
set -l code 1
if count $times > /dev/null
if count $times >/dev/null
for i in (seq $times)
# Try one step backward
if __fish_move_last dirprev dirnext;
if __fish_move_last dirprev dirnext
# We consider it a success if we were able to do at least 1 step
# (low expectations are the key to happiness ;)
set code 0

View file

@ -1,12 +1,14 @@
function prompt_pwd --description "Print the current working directory, shortened to fit the prompt"
set -q argv[1]; and switch $argv[1]
set -q argv[1]
and switch $argv[1]
case -h --help
__fish_print_help prompt_pwd
return 0
end
# This allows overriding fish_prompt_pwd_dir_length from the outside (global or universal) without leaking it
set -q fish_prompt_pwd_dir_length; or set -l fish_prompt_pwd_dir_length 1
set -q fish_prompt_pwd_dir_length
or set -l fish_prompt_pwd_dir_length 1
# Replace $HOME with "~"
set realhome ~

View file

@ -60,7 +60,8 @@ function psub --description "Read from stdin into a file and output the filename
# Write output to pipe. This needs to be done in the background so
# that the command substitution exits without needing to wait for
# all the commands to exit
set dirname (mktemp -d "$TMPDIR[1]"/.psub.XXXXXXXXXX); or return
set dirname (mktemp -d "$TMPDIR[1]"/.psub.XXXXXXXXXX)
or return
set filename $dirname/psub.fifo"$suffix"
mkfifo $filename
cat >$filename &
@ -78,9 +79,11 @@ function psub --description "Read from stdin into a file and output the filename
# Find unique function name
while true
set funcname __fish_psub_(random);
set funcname __fish_psub_(random)
if not functions $funcname >/dev/null ^/dev/null
break;
break
end
end

View file

@ -1,5 +1,6 @@
function suspend -d "Suspend the current shell."
if contains -- $argv --help; or contains -- $argv -h
if contains -- $argv --help
or contains -- $argv -h
__fish_print_help suspend
and return 0
end

View file

@ -25,7 +25,7 @@ function trap -d 'Perform an action when the shell receives a signal'
set -l options
set -l longopt
set -l shortopt lph
if not getopt -T > /dev/null
if not getopt -T >/dev/null
# GNU getopt
set longopt print,help,list-signals
set options -o $shortopt -l $longopt --

View file

@ -143,7 +143,10 @@ function type --description "Print the type of a command"
end
end
if begin; test $found = 0; and test $mode != quiet; end
if begin
test $found = 0
and test $mode != quiet
end
printf (_ "%s: Could not find '%s'\n") type $i >&2
end

View file

@ -3,7 +3,9 @@ function __fish_umask_parse -d "Internal umask function"
# Test if already a valid octal mask, and pad it with zeros
if echo $argv | __fish_sgrep -E '^0?[0-7]{1,3}$' >/dev/null
set -l char_count (echo $argv| wc -c)
for i in (seq (math 5 - $char_count)); set argv 0$argv; end
for i in (seq (math 5 - $char_count))
set argv 0$argv
end
echo $argv
else
# Test if argument really is a valid symbolic mask
@ -72,7 +74,7 @@ function __fish_umask_parse -d "Internal umask function"
set mode set
end
if not echo $perm| __fish_sgrep -E '^(r|w|x)*$' >/dev/null
if not echo $perm | __fish_sgrep -E '^(r|w|x)*$' >/dev/null
printf (_ "%s: Invalid mask '%s'\n") umask $argv >&2
return
end
@ -131,7 +133,7 @@ function __fish_umask_print_symbolic
end
echo $res|cut -c 2-
echo $res | cut -c 2-
end
function umask --description "Set default file permission mask"