2005-09-20 21:31:55 +08:00
|
|
|
#
|
|
|
|
# Initializations that should only be performed when in interactive mode
|
|
|
|
#
|
|
|
|
|
|
|
|
if not status --is-interactive
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Print a greeting
|
|
|
|
#
|
|
|
|
|
2006-01-05 21:41:59 +08:00
|
|
|
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)
|
2005-09-20 21:31:55 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Set exit message
|
|
|
|
#
|
|
|
|
|
2006-01-05 21:41:59 +08:00
|
|
|
function fish_on_exit -d (_ "Commands to execute when fish exits") --on-process %self
|
|
|
|
printf (_ "Good bye\n")
|
2005-09-20 21:31:55 +08:00
|
|
|
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.
|
|
|
|
|
2006-01-05 21:41:59 +08:00
|
|
|
function fish_prompt -d (_ "Write out the prompt")
|
2006-01-28 18:25:51 +08:00
|
|
|
if not set -q __fish_prompt_whoami
|
|
|
|
set -g __fish_prompt_whoami (whoami)
|
|
|
|
end
|
|
|
|
|
|
|
|
if not set -q __fish_prompt_hostname
|
|
|
|
set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
if not set -q __fish_prompt_normal
|
|
|
|
set -g __fish_prompt_normal (set_color normal)
|
|
|
|
end
|
|
|
|
|
|
|
|
printf '%s@%s %s%s%s> \n' $__fish_prompt_whoami $__fish_prompt_hostname (set_color $fish_color_cwd) (prompt_pwd) $__fish_prompt_normal
|
2005-09-20 21:31:55 +08:00
|
|
|
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.
|
2005-11-03 22:35:35 +08:00
|
|
|
# Give priority to the default file installed with fish in
|
|
|
|
# @SYSCONFDIR@/fish_inputrc.
|
2005-09-20 21:31:55 +08:00
|
|
|
#
|
|
|
|
|
2006-01-22 05:12:39 +08:00
|
|
|
for i in ~/.fish_inputrc @SYSCONFDIR@/fish_inputrc ~/.inputrc /etc/inputrc
|
2005-09-20 21:31:55 +08:00
|
|
|
if test -f $i
|
|
|
|
set -xg INPUTRC $i
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Set various color values
|
|
|
|
#
|
|
|
|
|
2005-10-25 01:51:08 +08:00
|
|
|
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"
|
2005-09-23 04:16:52 +08:00
|
|
|
if not set -q $argv[1]
|
2005-09-20 21:31:55 +08:00
|
|
|
set -U -- $argv
|
2005-10-25 01:51:08 +08:00
|
|
|
return
|
2005-09-20 21:31:55 +08:00
|
|
|
end
|
2005-11-25 22:44:06 +08:00
|
|
|
if contains -- $$argv[1] (set_color -c)
|
2005-10-25 01:51:08 +08:00
|
|
|
return
|
|
|
|
end
|
|
|
|
set -U -- $argv
|
2005-09-20 21:31:55 +08:00
|
|
|
end
|
|
|
|
|
2005-09-23 04:16:52 +08:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2005-09-20 21:31:55 +08:00
|
|
|
# Regular syntax highlighting colors
|
2005-10-25 01:51:08 +08:00
|
|
|
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
|
2005-09-20 21:31:55 +08:00
|
|
|
|
2005-10-25 01:51:08 +08:00
|
|
|
set_default_color fish_color_cwd green
|
2005-09-20 21:31:55 +08:00
|
|
|
|
|
|
|
# Background color for matching quotes and parenthesis
|
2005-10-25 01:51:08 +08:00
|
|
|
set_default_color fish_color_match cyan
|
2005-09-20 21:31:55 +08:00
|
|
|
|
|
|
|
# Background color for search matches
|
2005-10-25 01:51:08 +08:00
|
|
|
set_default_color fish_color_search_match purple
|
2005-09-20 21:31:55 +08:00
|
|
|
|
|
|
|
# Pager colors
|
2005-10-25 01:51:08 +08:00
|
|
|
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
|
2005-09-20 21:31:55 +08:00
|
|
|
|
|
|
|
# Directory history colors
|
2005-10-25 01:51:08 +08:00
|
|
|
set_default_color fish_color_history_current cyan
|
2005-09-20 21:31:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Setup the CDPATH variable
|
|
|
|
#
|
|
|
|
|
2005-09-23 04:16:52 +08:00
|
|
|
set_exported_default CDPATH . ~
|
2005-09-20 21:31:55 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Match colors for grep, if supported
|
|
|
|
#
|
|
|
|
|
|
|
|
if grep --color=auto --help 1>/dev/null 2>/dev/null
|
2005-09-23 04:16:52 +08:00
|
|
|
set_exported_default GREP_COLOR '97;45'
|
|
|
|
set_exported_default GREP_OPTIONS '--color=auto'
|
2005-09-20 21:31:55 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Color definitions for ls, if supported
|
|
|
|
#
|
|
|
|
|
|
|
|
if command ls --color=auto --help 1>/dev/null 2>/dev/null
|
2005-09-23 04:16:52 +08:00
|
|
|
set_exported_default LS_COLORS $LS_COLORS '*.jar=01;31' '*.doc=35' '*.pdf=35' '*.ps=35' '*.xls=35' '*.swf=35' '*~=37'
|
2005-09-20 21:31:55 +08:00
|
|
|
end
|
|
|
|
|
2005-09-23 04:16:52 +08:00
|
|
|
|
2006-01-22 05:12:39 +08:00
|
|
|
#
|
|
|
|
# Remove temporary functions
|
|
|
|
#
|
|
|
|
|
2005-10-25 01:51:08 +08:00
|
|
|
functions -e set_default_color
|
2005-09-23 04:16:52 +08:00
|
|
|
functions -e set_exported_default
|