mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-05 01:33:41 +08:00
b33d3f78b1
darcs-hash:20060105170915-ac50b-4a31a54f30d8bfcfecdd8fb60b9639087b27925a.gz
124 lines
3.0 KiB
Fish
124 lines
3.0 KiB
Fish
#
|
|
# Initializations that should only be performed when in interactive mode
|
|
#
|
|
|
|
if not status --is-interactive
|
|
exit
|
|
end
|
|
|
|
#
|
|
# Print a greeting
|
|
#
|
|
|
|
printf (_ 'Welcome to fish, the friendly interactive shell\n')
|
|
printf (_ 'Type %shelp%s for instructions on how to use fish\n') (set_color green) (set_color normal)
|
|
|
|
#
|
|
# Set exit message
|
|
#
|
|
|
|
function fish_on_exit -d (_ "Commands to execute when fish exits") --on-process %self
|
|
printf (_ "Good bye\n")
|
|
end
|
|
|
|
# Set the default prompt command. Make sure that every terminal escape
|
|
# string has a newline before and after, so that fish will know how
|
|
# long it is.
|
|
|
|
function fish_prompt -d (_ "Write out the prompt")
|
|
printf '%s@%s %s%s%s> \n' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
|
|
end
|
|
|
|
#
|
|
# Set INPUTRC to something nice
|
|
#
|
|
# We override INPUTRC if already set, since it may be set by a shell
|
|
# other than fish, which may use a different file. The new value should
|
|
# be exported, since the fish inputrc file plays nice with other files
|
|
# by including them when found.
|
|
# Give priority to the default file installed with fish in
|
|
# @SYSCONFDIR@/fish_inputrc.
|
|
#
|
|
|
|
for i in ~/.fish_inputrc @SYSCONFDIR@/fish_inputrc ~/etc/fish_inputrc /etc/fish_inputrc ~/.inputrc /etc/inputrc
|
|
if test -f $i
|
|
set -xg INPUTRC $i
|
|
break
|
|
end
|
|
end
|
|
|
|
|
|
#
|
|
# Set various color values
|
|
#
|
|
|
|
function set_default_color -d "Set an universal variable, unless it has already been set. If set, verify that it is a valid color name"
|
|
if not set -q $argv[1]
|
|
set -U -- $argv
|
|
return
|
|
end
|
|
if contains -- $$argv[1] (set_color -c)
|
|
return
|
|
end
|
|
set -U -- $argv
|
|
end
|
|
|
|
function set_exported_default -d "Set an exported universal variable, unless it has already been set"
|
|
if not set -q $argv[1]
|
|
set -Ux -- $argv
|
|
end
|
|
end
|
|
|
|
|
|
# Regular syntax highlighting colors
|
|
set_default_color fish_color_normal normal
|
|
set_default_color fish_color_command green
|
|
set_default_color fish_color_redirection normal
|
|
set_default_color fish_color_comment brown
|
|
set_default_color fish_color_error red
|
|
|
|
set_default_color fish_color_cwd green
|
|
|
|
# Background color for matching quotes and parenthesis
|
|
set_default_color fish_color_match cyan
|
|
|
|
# Background color for search matches
|
|
set_default_color fish_color_search_match purple
|
|
|
|
# Pager colors
|
|
set_default_color fish_pager_color_prefix cyan
|
|
set_default_color fish_pager_color_completion normal
|
|
set_default_color fish_pager_color_description normal
|
|
set_default_color fish_pager_color_progress cyan
|
|
|
|
# Directory history colors
|
|
set_default_color fish_color_history_current cyan
|
|
|
|
|
|
#
|
|
# Setup the CDPATH variable
|
|
#
|
|
|
|
set_exported_default CDPATH . ~
|
|
|
|
#
|
|
# Match colors for grep, if supported
|
|
#
|
|
|
|
if grep --color=auto --help 1>/dev/null 2>/dev/null
|
|
set_exported_default GREP_COLOR '97;45'
|
|
set_exported_default GREP_OPTIONS '--color=auto'
|
|
end
|
|
|
|
#
|
|
# Color definitions for ls, if supported
|
|
#
|
|
|
|
if command ls --color=auto --help 1>/dev/null 2>/dev/null
|
|
set_exported_default LS_COLORS $LS_COLORS '*.jar=01;31' '*.doc=35' '*.pdf=35' '*.ps=35' '*.xls=35' '*.swf=35' '*~=37'
|
|
end
|
|
|
|
|
|
functions -e set_default_color
|
|
functions -e set_exported_default
|