diff options
-rw-r--r-- | init/fish_complete.fish.in | 1 | ||||
-rw-r--r-- | init/fish_function.fish | 129 | ||||
-rw-r--r-- | init/functions/__fish_describe_command.fish | 15 | ||||
-rw-r--r-- | init/functions/cd.fish | 35 | ||||
-rw-r--r-- | init/functions/contains.fish | 49 | ||||
-rw-r--r-- | init/functions/ll.fish | 7 | ||||
-rw-r--r-- | init/functions/pwd.fish | 7 | ||||
-rw-r--r-- | parse_util.c | 1 |
8 files changed, 114 insertions, 130 deletions
diff --git a/init/fish_complete.fish.in b/init/fish_complete.fish.in index 42619251..15f8d676 100644 --- a/init/fish_complete.fish.in +++ b/init/fish_complete.fish.in @@ -43,7 +43,6 @@ function __fish_complete_command -d "Complete using all available commands" end - function __fish_print_hostnames -d "Print a list of known hostnames" # Print all hosts from /etc/hosts diff --git a/init/fish_function.fish b/init/fish_function.fish index 4ddadc35..3f84a495 100644 --- a/init/fish_function.fish +++ b/init/fish_function.fish @@ -1,67 +1,6 @@ -# -# This file defines various shellscript functions. Most of them are -# meant to be used directly by the user, but some of them, typically -# the ones whose name start with '__fish_', are only meant to be used -# internally by fish. -# - -function contains -d "Test if a key is contained in a set of values" - while set -q argv - switch $argv[1] - case '-h' '--h' '--he' '--hel' '--help' - help contains - return - - case '--' - # End the loop, the next argument is the key - set -e argv[1] - break - - case '-*' - printf (_ "%s: Unknown option '%s'\n") contains $argv[$i] - help contains - return 1 - - case '*' - # End the loop, we found the key - break - - end - set -e argv[1] - end - - if not set -q argv - printf (_ "%s: Key not specified\n") contains - return 1 - end - - set -- key $argv[1] - set -e argv[1] - - # - # Loop through values - # - - printf "%s\n" $argv|grep -Fx -- $key >/dev/null - return $status -end - - # -# These are very common and useful -# -function ll -d "List contents of directory using long format" - ls -lh $argv -end - -function la -d "List contents of directory using long format, showing hidden files" - ls -lha $argv -end - - -# -# Print the current working directory in a shortened form.This +# Print the current working directory in a shortened form. This # function is used by the default prompt command. # @@ -85,28 +24,6 @@ else end end -# -# Make pwd print out the home directory as a tilde. -# - -function pwd -d "Print working directory" - command pwd | sed -e 's|/private||' -e "s|^$HOME|~|" -end - -# -# This function is used internally by the fish command completion code -# - -function __fish_describe_command -d "Command used to find descriptions for commands" - apropos $argv | awk -v FS=" +- +" '{ - split($1, names, ", "); - for (name in names) - if (names[name] ~ /^'"$argv"'.* *\([18]\)/) { - sub("\\([18]\\)", "", names[name]); - print names[name] "\t" $2; - } - }' -end # # This function is bound to Alt-L, it is used to list the contents of @@ -157,50 +74,6 @@ function dirs -d "Print directory stack" end -# -# The following functions add support for a directory history -# - -function cd -d "Change directory" - - # Skip history in subshells - if status --is-command-substitution - builtin cd $argv - return $status - end - - # Avoid set completions - set previous (command pwd) - - if test $argv[1] = - ^/dev/null - if test $__fish_cd_direction = next ^/dev/null - nextd - else - prevd - end - return $status - end - - builtin cd $argv[1] - - if test $status = 0 -a (command pwd) != $previous - set -g dirprev $dirprev $previous - set -e dirnext - set -g __fish_cd_direction prev - end - - return $status -end - - - -function __bold -d "Print argument in bold" - set_color --bold - printf "%s" $argv[1] - set_color normal -end - - function prevd-or-backward-word --key-binding if test -z (commandline) prevd diff --git a/init/functions/__fish_describe_command.fish b/init/functions/__fish_describe_command.fish new file mode 100644 index 00000000..27d478b7 --- /dev/null +++ b/init/functions/__fish_describe_command.fish @@ -0,0 +1,15 @@ +# +# This function is used internally by the fish command completion code +# + +function __fish_describe_command -d "Command used to find descriptions for commands" + apropos $argv | awk -v FS=" +- +" '{ + split($1, names, ", "); + for (name in names) + if (names[name] ~ /^'"$argv"'.* *\([18]\)/) { + sub("\\([18]\\)", "", names[name]); + print names[name] "\t" $2; + } + }' +end + diff --git a/init/functions/cd.fish b/init/functions/cd.fish new file mode 100644 index 00000000..3fef9136 --- /dev/null +++ b/init/functions/cd.fish @@ -0,0 +1,35 @@ +# +# The following functions add support for a directory history +# + +function cd -d "Change directory" + + # Skip history in subshells + if status --is-command-substitution + builtin cd $argv + return $status + end + + # Avoid set completions + set previous (command pwd) + + if test $argv[1] = - ^/dev/null + if test $__fish_cd_direction = next ^/dev/null + nextd + else + prevd + end + return $status + end + + builtin cd $argv[1] + + if test $status = 0 -a (command pwd) != $previous + set -g dirprev $dirprev $previous + set -e dirnext + set -g __fish_cd_direction prev + end + + return $status +end + diff --git a/init/functions/contains.fish b/init/functions/contains.fish new file mode 100644 index 00000000..76694608 --- /dev/null +++ b/init/functions/contains.fish @@ -0,0 +1,49 @@ +# +# This file defines various shellscript functions. Most of them are +# meant to be used directly by the user, but some of them, typically +# the ones whose name start with '__fish_', are only meant to be used +# internally by fish. +# + +function contains -d "Test if a key is contained in a set of values" + while set -q argv + switch $argv[1] + case '-h' '--h' '--he' '--hel' '--help' + help contains + return + + case '--' + # End the loop, the next argument is the key + set -e argv[1] + break + + case '-*' + printf (_ "%s: Unknown option '%s'\n") contains $argv[$i] + help contains + return 1 + + case '*' + # End the loop, we found the key + break + + end + set -e argv[1] + end + + if not set -q argv + printf (_ "%s: Key not specified\n") contains + return 1 + end + + set -- key $argv[1] + set -e argv[1] + + # + # Loop through values + # + + printf "%s\n" $argv|grep -Fx -- $key >/dev/null + return $status +end + + diff --git a/init/functions/ll.fish b/init/functions/ll.fish new file mode 100644 index 00000000..9f811401 --- /dev/null +++ b/init/functions/ll.fish @@ -0,0 +1,7 @@ +# +# These are very common and useful +# +function ll -d "List contents of directory using long format" + ls -lh $argv +end + diff --git a/init/functions/pwd.fish b/init/functions/pwd.fish new file mode 100644 index 00000000..3d397aeb --- /dev/null +++ b/init/functions/pwd.fish @@ -0,0 +1,7 @@ +# +# Make pwd print out the home directory as a tilde. +# + +function pwd -d "Print working directory" + command pwd | sed -e 's|/private||' -e "s|^$HOME|~|" +end diff --git a/parse_util.c b/parse_util.c index 62024189..216a1a03 100644 --- a/parse_util.c +++ b/parse_util.c @@ -474,7 +474,6 @@ int parse_util_load( const wchar_t *cmd, */ if( !reload && tm ) return 0; - debug( 1, L"WOO %ls", cmd ); al_init( &path_list ); |