mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
Make sure fish color settings are valid colors
darcs-hash:20051024175108-ac50b-3abfbd8b5974c7a3a53bc70d425d41dd1295da02.gz
This commit is contained in:
parent
277f9b7e60
commit
48afe8062e
5 changed files with 45 additions and 23 deletions
|
@ -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,
|
COLOR is one of black, red, green, brown, yellow, blue, magenta,
|
||||||
purple, cyan, white and normal.
|
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 -b, \c --background Set the background color
|
||||||
- \c -o, \c --bold Set bold or extra bright mode
|
- \c -o, \c --bold Set bold or extra bright mode
|
||||||
- \c -h, \c --help Display help message and exit
|
- \c -h, \c --help Display help message and exit
|
||||||
- \c -v, \c --version Display version and exit
|
- \c -v, \c --version Display version and exit
|
||||||
|
|
||||||
|
|
||||||
Calling <tt>set_color normal</tt> will set the terminal color to
|
Calling <tt>set_color normal</tt> will set the terminal color to
|
||||||
whatever is the default color of the terminal.
|
whatever is the default color of the terminal.
|
||||||
|
|
||||||
|
|
|
@ -43,4 +43,4 @@ function __fish_set_is_color -d 'Test if We are specifying a color value for the
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|
|
@ -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 '(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 -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 -s o -l bold -d 'Make font bold'
|
complete -c set_color -s o -l bold -d 'Make font bold'
|
||||||
|
|
|
@ -53,10 +53,15 @@ end
|
||||||
# Set various color values
|
# 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]
|
if not set -q $argv[1]
|
||||||
set -U -- $argv
|
set -U -- $argv
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
if contains $$argv[1] (set_color --print-colors)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
set -U -- $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
function set_exported_default -d "Set an exported universal variable, unless it has already been set"
|
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
|
# Regular syntax highlighting colors
|
||||||
set_default fish_color_normal normal
|
set_default_color fish_color_normal normal
|
||||||
set_default fish_color_command green
|
set_default_color fish_color_command green
|
||||||
set_default fish_color_redirection normal
|
set_default_color fish_color_redirection normal
|
||||||
set_default fish_color_comment brown
|
set_default_color fish_color_comment brown
|
||||||
set_default fish_color_error red
|
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
|
# 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
|
# Background color for search matches
|
||||||
set_default fish_color_search_match purple
|
set_default_color fish_color_search_match purple
|
||||||
|
|
||||||
# Pager colors
|
# Pager colors
|
||||||
set_default fish_pager_color_prefix cyan
|
set_default_color fish_pager_color_prefix cyan
|
||||||
set_default fish_pager_color_completion normal
|
set_default_color fish_pager_color_completion normal
|
||||||
set_default fish_pager_color_description normal
|
set_default_color fish_pager_color_description normal
|
||||||
set_default fish_pager_color_progress cyan
|
set_default_color fish_pager_color_progress cyan
|
||||||
|
|
||||||
# Directory history colors
|
# 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
|
end
|
||||||
|
|
||||||
|
|
||||||
functions -e set_default
|
functions -e set_default_color
|
||||||
functions -e set_exported_default
|
functions -e set_exported_default
|
||||||
|
|
23
set_color.c
23
set_color.c
|
@ -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 )
|
int main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
char *bgcolor=0;
|
char *bgcolor=0;
|
||||||
char *fgcolor=0;
|
char *fgcolor=0;
|
||||||
int fg, bg;
|
int fg, bg;
|
||||||
int bold=0;
|
int bold=0;
|
||||||
|
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
|
@ -125,6 +134,10 @@ int main( int argc, char **argv )
|
||||||
"version", no_argument, 0, 'v'
|
"version", no_argument, 0, 'v'
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
|
{
|
||||||
|
"print-colors", no_argument, 0, 'c'
|
||||||
|
}
|
||||||
|
,
|
||||||
{
|
{
|
||||||
0, 0, 0, 0
|
0, 0, 0, 0
|
||||||
}
|
}
|
||||||
|
@ -135,13 +148,13 @@ int main( int argc, char **argv )
|
||||||
|
|
||||||
int opt = getopt_long( argc,
|
int opt = getopt_long( argc,
|
||||||
argv,
|
argv,
|
||||||
"b:hvo",
|
"b:hvoc",
|
||||||
long_options,
|
long_options,
|
||||||
&opt_index );
|
&opt_index );
|
||||||
#else
|
#else
|
||||||
int opt = getopt( argc,
|
int opt = getopt( argc,
|
||||||
argv,
|
argv,
|
||||||
"b:hvo" );
|
"b:hvoc" );
|
||||||
#endif
|
#endif
|
||||||
if( opt == -1 )
|
if( opt == -1 )
|
||||||
break;
|
break;
|
||||||
|
@ -166,6 +179,10 @@ int main( int argc, char **argv )
|
||||||
fprintf( stderr, "set_color, version %s\n", PACKAGE_VERSION );
|
fprintf( stderr, "set_color, version %s\n", PACKAGE_VERSION );
|
||||||
exit( 0 );
|
exit( 0 );
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
print_colors();
|
||||||
|
exit(0);
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue