This change allows for customizing of the clipboard buffer, by supplying

a command to accept the "copy".  So, you add your clipboard buffer command
to an environment variable, and custom commands will be used for the copy
program.  Very useful when your OS is not naitively supported by fish.
This commit is contained in:
David Frascone 2010-11-05 09:32:05 -06:00
parent 4f0221bc4f
commit 8a46a8ecb2

60
kill.c
View File

@ -92,28 +92,52 @@ static void kill_add_internal( wchar_t *str )
void kill_add( wchar_t *str )
{
wchar_t *cmd = NULL;
wchar_t *escaped_str;
kill_add_internal(str);
if( !has_xsel() )
return;
/* This is for sending the kill to the X copy-and-paste buffer */
wchar_t *disp;
if( (disp = env_get( L"DISPLAY" )) )
{
wchar_t *escaped_str = escape( str, 1 );
wchar_t *cmd = wcsdupcat(L"echo ", escaped_str, L"|xsel -b" );
if( exec_subshell( cmd, 0 ) == -1 )
{
/*
Do nothing on failiure
*/
}
free( cut_buffer );
free( cmd );
/*
Check to see if user has set the FISH_CLIPBOARD_CMD variable,
and, if so, use it instead of checking the display, etc.
I couldn't think of a safe way to allow overide of the echo
command too, so, the command used must accept the input via stdin.
*/
wchar_t *clipboard;
if( (clipboard = env_get(L"FISH_CLIPBOARD_CMD")) )
{
escaped_str = escape( str, 1 );
cmd = wcsdupcat(L"echo -n ", escaped_str, clipboard);
}
else
{
/* This is for sending the kill to the X copy-and-paste buffer */
if( !has_xsel() ) {
return;
}
wchar_t *disp;
if( (disp = env_get( L"DISPLAY" )) )
{
escaped_str = escape( str, 1 );
cmd = wcsdupcat(L"echo ", escaped_str, L"|xsel -b" );
}
}
if (cmd != NULL)
{
if( exec_subshell( cmd, 0 ) == -1 )
{
/*
Do nothing on failiure
*/
}
free( cut_buffer );
free( cmd );
cut_buffer = escaped_str;
cut_buffer = escaped_str;
}
}