Move a few shellscript bits around

darcs-hash:20060218024145-ac50b-207ca782808ea8968cb38253c7bc2563350f38b2.gz
This commit is contained in:
axel 2006-02-18 12:41:45 +10:00
parent 7073f0b58b
commit dd79d75504
5 changed files with 56 additions and 162 deletions

103
etc/fish
View File

@ -1,103 +0,0 @@
#
# Init file for fish
#
# etc/fish. Generated from fish.in by configure.
#
# Set default search paths
#
set -g fish_function_path ~/.fish.d/functions /etc/fish.d/functions /usr/share/functions
set -g fish_complete_path ~/.fish.d/completions /etc/fish.d/completions /usr/share/completions
#
# Set default field separators
#
set -g IFS \ \t\n
#
# 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 /usr/bin /sw/bin
# 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
#
# Set some value for LANG if nothing was set before, and this is a
# login shell. Also check for i18n information in /etc/sysconfig/i18n
#
if status --is-login
if not set -q LANG >/dev/null
set -gx LANG en_US.UTF-8
end
if test -f /etc/sysconfig/i18n
eval (cat /etc/sysconfig/i18n |sed -ne 's/^\([a-zA-Z]*\)=\(.*\)$/set -gx \1 \2;/p')
end
end
#
# Put linux console in unicode mode. Should this be done in any other
# situation as well?
#
if expr "$LANG" : ".*[Uu][Tt][Ff]" >/dev/null
if test linux = "$TERM"
unicode_start ^/dev/null
end
end
#
# There are variables that contain colons that are not arrays. This
# reverts them back to regular strings.
#
for i in DISPLAY
if set -q $i
set -- $i (printf ":%s" $$i|cut -c 2-)
end
end
#
# Alias for gettext (or a fallback if gettext isn't installed) This
# needs to be defined here and not in fish_function.fish, since it is
# used by other init files.
#
function _ -d "Alias for the gettext command"
printf "%s" $argv
end
if test 1 = "1"
if which gettext ^/dev/null >/dev/null
function _ -d "Alias for the gettext command"
gettext fish $argv
end
end
end
#
# Load additional initialization files
#
for i in fish.d/*.fish
. $i
end

View File

@ -38,22 +38,6 @@ for i in $path_list
end
#
# Set some value for LANG if nothing was set before, and this is a
# login shell. Also check for i18n information in /etc/sysconfig/i18n
#
if status --is-login
if not set -q LANG >/dev/null
set -gx LANG en_US.UTF-8
end
if test -f /etc/sysconfig/i18n
eval (cat /etc/sysconfig/i18n |sed -ne 's/^\([a-zA-Z]*\)=\(.*\)$/set -gx \1 \2;/p')
end
end
#
# Put linux console in unicode mode. Should this be done in any other
# situation as well?
@ -77,23 +61,6 @@ for i in DISPLAY
end
end
#
# Alias for gettext (or a fallback if gettext isn't installed) This
# needs to be defined here and not in fish_function.fish, since it is
# used by other init files.
#
function _ -d "Alias for the gettext command"
printf "%s" $argv
end
if test 1 = "@HAVE_GETTEXT@"
if which gettext ^/dev/null >/dev/null
function _ -d "Alias for the gettext command"
gettext fish $argv
end
end
end
#
# Load additional initialization files
#

View File

@ -13,6 +13,38 @@ set -g fish_function_path
# Don't need completions in non-interactive mode
#
#
# Alias for gettext (or a fallback if gettext isn't installed) This
# needs to be defined here and not in fish_function.fish, since it is
# used by other init files.
#
function _ -d "Alias for the gettext command"
printf "%s" $argv
end
if test 1 = "1"
if which gettext ^/dev/null >/dev/null
function _ -d "Alias for the gettext command"
gettext fish $argv
end
end
end
#
# Set some value for LANG if nothing was set before, and this is a
# login shell. Also check for i18n information in /etc/sysconfig/i18n
#
if status --is-login
if not set -q LANG >/dev/null
set -gx LANG en_US.UTF-8
end
if test -f /etc/sysconfig/i18n
eval (cat /etc/sysconfig/i18n |sed -ne 's/^\([a-zA-Z]*\)=\(.*\)$/set -gx \1 \2;/p')
end
end
if not status --is-interactive
exit
end
@ -55,36 +87,10 @@ end
set -l __fish_help_desc (_ "Display help and exit")
for i in (builtin -n|grep -vE '(while|for|if|function|switch)' )
complete -c $i -s h -l help -d $__fish_help_desc
end
function __fish_append -d "Internal completion function for appending string to the commandline"
set separator $argv[1]
set -e argv[1]
set str (commandline -tc| sed -ne "s/\(.*$separator\)[^$separator]*/\1/p"|sed -e "s/--.*=//")
printf "%s\n" "$str"$argv "$str"(printf "%s\n" $argv|sed -e "s/\(\t\|\$\)/,\1/")
end
#
# Test to see if we've seen a subcommand from a list.
# This logic may seem backwards, but the commandline will often be much shorter
# than the list
#
function __fish_seen_subcommand_from
set -l -- cmd (commandline -poc)
set -e cmd[1]
for i in $cmd
if contains -- $i $argv
return 0
end
end
return 1
end
#
# Completions for SysV startup scripts
#

View File

@ -0,0 +1,8 @@
function __fish_append -d "Internal completion function for appending string to the commandline"
set separator $argv[1]
set -e argv[1]
set str (commandline -tc| sed -ne "s/\(.*$separator\)[^$separator]*/\1/p"|sed -e "s/--.*=//")
printf "%s\n" "$str"$argv "$str"(printf "%s\n" $argv|sed -e "s/\(\t\|\$\)/,\1/")
end

View File

@ -0,0 +1,16 @@
#
# Test to see if we've seen a subcommand from a list.
# This logic may seem backwards, but the commandline will often be much shorter
# than the list
#
function __fish_seen_subcommand_from
set -l -- cmd (commandline -poc)
set -e cmd[1]
for i in $cmd
if contains -- $i $argv
return 0
end
end
return 1
end