From 99a93b5add6ce77b619f8b72499dc58a91024522 Mon Sep 17 00:00:00 2001 From: npilon Date: Tue, 14 Mar 2006 05:07:24 +1000 Subject: Fish PATH Fix Moved PATH detection code to the start of share/fish. darcs-hash:20060313190724-c90d9-8e2e80910041e91b48d68154e9d8180d04689463.gz --- Makefile.in | 2 +- configure.ac | 2 +- etc/fish.in | 3 -- share/fish | 71 --------------------------------------------- share/fish.in | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 76 deletions(-) delete mode 100644 share/fish create mode 100644 share/fish.in diff --git a/Makefile.in b/Makefile.in index 12176df5..c37cd7fb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -179,7 +179,7 @@ ETC_DIR_FILES :=etc/fish.in etc/fish_inputrc \ etc/fish_interactive.fish.in # Files in ./share/ -SHARE_DIR_FILES :=share/fish +SHARE_DIR_FILES :=share/fish.in # Files in ./tests/ TESTS_DIR_FILES := $(TEST_IN) $(TEST_IN:.in=.out) $(TEST_IN:.in=.err) \ diff --git a/configure.ac b/configure.ac index 49135507..de3b4756 100644 --- a/configure.ac +++ b/configure.ac @@ -292,7 +292,7 @@ else fi # Tell the world what we know -AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile etc/fish etc/fish_interactive.fish seq]) +AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile etc/fish etc/fish_interactive.fish share/fish seq]) AC_OUTPUT echo "fish is now configured." diff --git a/etc/fish.in b/etc/fish.in index b05a27dc..90da43ef 100644 --- a/etc/fish.in +++ b/etc/fish.in @@ -24,10 +24,7 @@ set -g IFS \ \t\n set -l path_list /bin /usr/bin /usr/X11R6/bin @PREFIX@/bin @optbindirs@ -# # Root should also have the sbin directories in the path -# - if test "$USER" = root set path_list $path_list /sbin /usr/sbin /usr/local/sbin end diff --git a/share/fish b/share/fish deleted file mode 100644 index f3b1a273..00000000 --- a/share/fish +++ /dev/null @@ -1,71 +0,0 @@ -# -# Main file for fish command completions. This file contains various -# common helper functions for the command completions. All actual -# completions are located in the completions subdirectory. -# - -# -# Assign a temporary value here for performance reasons. The real value should be set in /etc/fish. -# - -set -g fish_function_path $PWD/functions/ - -# -# Don't need completions in non-interactive mode -# - -if not status --is-interactive - exit -end - -# -# Convenience functions -# -# The naming heuristic is that __fish_complete_* prints completions -# and descriptions, while __fish_print_* only prints the completion, -# without the description -# - -function __fish_complete_users -d "Print a list of local users, with the real user name as a description" - cat /etc/passwd | sed -e "s/^\([^:]*\):[^:]*:[^:]*:[^:]*:\([^:]*\):.*/\1\t\2/" -end - -function __fish_complete_groups -d "Print a list of local groups, with group members as the description" - cat /etc/group | sed -e "s/^\([^:]*\):[^:]*:[^:]*:\(.*\)/\1\tMembers: \2/" -end - -function __fish_complete_command -d "Complete using all available commands" - printf "%s\n" (commandline -ct)(complete -C (commandline -ct)) -end - -function __fish_print_interfaces -d "Print a list of known network interfaces" - netstat -i -n -a | awk 'NR>2'|awk '{print $1}' -end - -function __fish_print_addresses -d "Print a list of known network addresses" - /sbin/ifconfig |grep 'inet addr'|cut -d : -f 2|cut -d ' ' -f 1 -end - -function __fish_print_users -d "Print a list of local users" - cat /etc/passwd | cut -d : -f 1 -end - -# -# Completions for the shell and it's builtin commands and functions -# - -for i in (builtin -n|grep -v '\(while\|for\|if\|function\|switch\)' ) - complete -c $i -s h -l help -d "Display help and exit" -end - - -# -# Completions for SysV startup scripts -# - -complete -x -p "/etc/init.d/*" -a start\t(_ 'Start service') -complete -x -p "/etc/init.d/*" -a stop\t(_ 'Stop service') -complete -x -p "/etc/init.d/*" -a status\t(_ 'Print service status') -complete -x -p "/etc/init.d/*" -a restart\t(_ 'Stop and then start service') -complete -x -p "/etc/init.d/*" -a reload\t(_ 'Reload service configuration') - diff --git a/share/fish.in b/share/fish.in new file mode 100644 index 00000000..a74e7438 --- /dev/null +++ b/share/fish.in @@ -0,0 +1,92 @@ +# +# Main file for fish command completions. This file contains various +# common helper functions for the command completions. All actual +# completions are located in the completions subdirectory. +# + +# +# Add a few common directories to path, if they exists. Note that pure +# console programs like makedep sometimes live in /usr/X11R6/bin, so we +# want this even for text-only terminals. +# + +set -l path_list /bin /usr/bin /usr/X11R6/bin @PREFIX@/bin @optbindirs@ + +# Root should also have the sbin directories in the path +if test "$USER" = root + set path_list $path_list /sbin /usr/sbin /usr/local/sbin +end + +for i in $path_list + if not expr "$PATH" : .\*$i.\* >/dev/null + if test -d $i + set PATH $PATH $i + end + end +end + +# +# Assign a temporary value here for performance reasons. The real value should be set in /etc/fish. +# + +set -g fish_function_path $PWD/functions/ + +# +# Don't need completions in non-interactive mode +# + +if not status --is-interactive + exit +end + +# +# Convenience functions +# +# The naming heuristic is that __fish_complete_* prints completions +# and descriptions, while __fish_print_* only prints the completion, +# without the description +# + +function __fish_complete_users -d "Print a list of local users, with the real user name as a description" + cat /etc/passwd | sed -e "s/^\([^:]*\):[^:]*:[^:]*:[^:]*:\([^:]*\):.*/\1\t\2/" +end + +function __fish_complete_groups -d "Print a list of local groups, with group members as the description" + cat /etc/group | sed -e "s/^\([^:]*\):[^:]*:[^:]*:\(.*\)/\1\tMembers: \2/" +end + +function __fish_complete_command -d "Complete using all available commands" + printf "%s\n" (commandline -ct)(complete -C (commandline -ct)) +end + +function __fish_print_interfaces -d "Print a list of known network interfaces" + netstat -i -n -a | awk 'NR>2'|awk '{print $1}' +end + +function __fish_print_addresses -d "Print a list of known network addresses" + /sbin/ifconfig |grep 'inet addr'|cut -d : -f 2|cut -d ' ' -f 1 +end + +function __fish_print_users -d "Print a list of local users" + cat /etc/passwd | cut -d : -f 1 +end + +# +# Completions for the shell and it's builtin commands and functions +# + +for i in (builtin -n|grep -v '\(while\|for\|if\|function\|switch\)' ) + complete -c $i -s h -l help -d "Display help and exit" +end + + +# +# Completions for SysV startup scripts +# + +complete -x -p "/etc/init.d/*" -a start\t(_ 'Start service') +complete -x -p "/etc/init.d/*" -a stop\t(_ 'Stop service') +complete -x -p "/etc/init.d/*" -a status\t(_ 'Print service status') +complete -x -p "/etc/init.d/*" -a restart\t(_ 'Stop and then start service') +complete -x -p "/etc/init.d/*" -a reload\t(_ 'Reload service configuration') + -- cgit v1.2.3