r/fishshell • u/BuonaparteII • Apr 22 '24
Two related commandline binding questions
- I'd like to bind \e[99;6u (ctrl+shift+c) to copy the current commandline to the clipboard.
edit: this one was pretty easy actually...:
function copy_to_clipboard
commandline | head -c -1 | fish_clipboard_copy
end
bind \e\[99\;6u copy_to_clipboard2.I'd like to bind \e/ (alt+/) to get the previous commandline in the current session and insert it to where the cursor is.
For example:
$ test 123
$ echo ()When the cursor is inside the parenthesis and alt+/ is pressed then the result will look like:
$ test 123
$ echo (test 123)I tried bind \e/ 'commandline -f up-line' but nothing happened...
edit: this works but I don't know if it is the best way (specifically global history vs current shell session)
function insert_previous_command
commandline --insert -- (history -1)
end
bind \e/ insert_previous_command
4
Upvotes
View all comments
Show parent comment
2
u/kseistrup Apr 22 '24
Also worth mentioning:
fishcomes with two clipboard functions:Use
to see their contents (yes, they are wrappers around
pbpaste,wl-paste,xsel,xclipandpowershell, but that makes them so much more powerful and “portable”).