From 7d1f45e25f8f7c0bdf0af7d96a60b148b8f54dd3 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 24 May 2016 13:17:03 +0200 Subject: Add clipboard helper functions and bind them \cy copies, \cv pastes. --- share/functions/fish_clipboard_copy.fish | 7 +++++++ share/functions/fish_clipboard_paste.fish | 7 +++++++ share/functions/fish_default_key_bindings.fish | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 share/functions/fish_clipboard_copy.fish create mode 100644 share/functions/fish_clipboard_paste.fish diff --git a/share/functions/fish_clipboard_copy.fish b/share/functions/fish_clipboard_copy.fish new file mode 100644 index 00000000..a65efc04 --- /dev/null +++ b/share/functions/fish_clipboard_copy.fish @@ -0,0 +1,7 @@ +function fish_clipboard_copy + if type -q pbcopy + commandline | pbcopy + else if type -q xsel + commandline | xsel --clipboard + end +end diff --git a/share/functions/fish_clipboard_paste.fish b/share/functions/fish_clipboard_paste.fish new file mode 100644 index 00000000..bec43c88 --- /dev/null +++ b/share/functions/fish_clipboard_paste.fish @@ -0,0 +1,7 @@ +function fish_clipboard_paste + if type -q pbpaste + commandline -i (pbpaste) + else if type -q xsel + commandline -i (xsel --clipboard) + end +end diff --git a/share/functions/fish_default_key_bindings.fish b/share/functions/fish_default_key_bindings.fish index e5491321..41b252f9 100644 --- a/share/functions/fish_default_key_bindings.fish +++ b/share/functions/fish_default_key_bindings.fish @@ -18,7 +18,8 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis bind $argv \r execute bind $argv \ck kill-line - bind $argv \cy yank + bind $argv \cy fish_clipboard_copy + bind $argv \cv fish_clipboard_paste bind $argv \t complete bind $argv \e\n "commandline -i \n" -- cgit v1.2.3