Make sure fish color settings are valid colors

darcs-hash:20051024175108-ac50b-3abfbd8b5974c7a3a53bc70d425d41dd1295da02.gz
This commit is contained in:
axel 2005-10-25 03:51:08 +10:00
parent 277f9b7e60
commit 48afe8062e
5 changed files with 45 additions and 23 deletions

View file

@ -10,11 +10,13 @@ Change the foreground and/or background color of the terminal.
COLOR is one of black, red, green, brown, yellow, blue, magenta,
purple, cyan, white and normal.
- \c -c, \c --print-colors Prints a list of all valid color names
- \c -b, \c --background Set the background color
- \c -o, \c --bold Set bold or extra bright mode
- \c -h, \c --help Display help message and exit
- \c -v, \c --version Display version and exit
Calling <tt>set_color normal</tt> will set the terminal color to
whatever is the default color of the terminal.

View file

@ -43,4 +43,4 @@ function __fish_set_is_color -d 'Test if We are specifying a color value for the
end
end
complete -c set -n '__fish_set_is_color' -x -a '$__fish_colors' -d Color
complete -c set -n '__fish_set_is_color' -x -a '(set_color --print-colors)' -d Color

View file

@ -1,5 +1,3 @@
set -g __fish_colors black red green brown blue magenta cyan white normal
complete -c set_color -x -d "Color" -a '$__fish_colors'
complete -c set_color -s b -l background -x -a '$__fish_colors' -d "Change background color"
complete -c set_color -x -d "Color" -a '(set_color --print-colors)'
complete -c set_color -s b -l background -x -a '(set_color --print-colors)' -d "Change background color"
complete -c set_color -s o -l bold -d 'Make font bold'

View file

@ -53,10 +53,15 @@ end
# Set various color values
#
function set_default -d "Set an universal variable, unless it has already been set"
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 --print-colors)
return
end
set -U -- $argv
end
function set_exported_default -d "Set an exported universal variable, unless it has already been set"
@ -67,28 +72,28 @@ end
# Regular syntax highlighting colors
set_default fish_color_normal normal
set_default fish_color_command green
set_default fish_color_redirection normal
set_default fish_color_comment brown
set_default fish_color_error red
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 fish_color_cwd green
set_default_color fish_color_cwd green
# Background color for matching quotes and parenthesis
set_default fish_color_match cyan
set_default_color fish_color_match cyan
# Background color for search matches
set_default fish_color_search_match purple
set_default_color fish_color_search_match purple
# Pager colors
set_default fish_pager_color_prefix cyan
set_default fish_pager_color_completion normal
set_default fish_pager_color_description normal
set_default fish_pager_color_progress cyan
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 fish_color_history_current cyan
set_default_color fish_color_history_current cyan
#
@ -115,5 +120,5 @@ if command ls --color=auto --help 1>/dev/null 2>/dev/null
end
functions -e set_default
functions -e set_default_color
functions -e set_exported_default

View file

@ -96,13 +96,22 @@ int translate_color( char *str )
}
void print_colors()
{
int i;
for( i=0; i<COLORS; i++ )
{
printf( "%s\n", col[i] );
}
}
int main( int argc, char **argv )
{
char *bgcolor=0;
char *fgcolor=0;
int fg, bg;
int bold=0;
while( 1 )
{
#ifdef __GLIBC__
@ -125,6 +134,10 @@ int main( int argc, char **argv )
"version", no_argument, 0, 'v'
}
,
{
"print-colors", no_argument, 0, 'c'
}
,
{
0, 0, 0, 0
}
@ -135,13 +148,13 @@ int main( int argc, char **argv )
int opt = getopt_long( argc,
argv,
"b:hvo",
"b:hvoc",
long_options,
&opt_index );
#else
int opt = getopt( argc,
argv,
"b:hvo" );
"b:hvoc" );
#endif
if( opt == -1 )
break;
@ -166,6 +179,10 @@ int main( int argc, char **argv )
fprintf( stderr, "set_color, version %s\n", PACKAGE_VERSION );
exit( 0 );
case 'c':
print_colors();
exit(0);
case '?':
return 1;