aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--kill.c60
1 files changed, 42 insertions, 18 deletions
diff --git a/kill.c b/kill.c
index 33201e1b..c80bbbe9 100644
--- a/kill.c
+++ b/kill.c
@@ -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;
}
}