mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 21:21:15 -03:00
Fix default Alt+W keybinding (#6110)
* Fix default Alt+W keybinding The old keybinding would chop off the last line of the `whatis` output when using a multi-line prompt. This fix corrects that. * Make variable local and remove unneeded if statement * Test that token is non-empty
This commit is contained in:
committed by
Fabian Homborg
parent
87dee7ad1c
commit
e5fc8abefe
@@ -80,7 +80,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
||||
bind --preset $argv \e. history-token-search-backward
|
||||
|
||||
bind --preset $argv \el __fish_list_current_token
|
||||
bind --preset $argv \ew 'set tok (commandline -pt); if test -n "$tok[1]"; echo; whatis $tok[1]; commandline -f repaint; end'
|
||||
bind --preset $argv \ew __fish_whatis_current_token
|
||||
# ncurses > 6.0 sends a "delete scrollback" sequence along with clear.
|
||||
# This string replace removes it.
|
||||
bind --preset $argv \cl 'echo -n (clear | string replace \e\[3J ""); commandline -f repaint'
|
||||
|
||||
17
share/functions/__fish_whatis_current_token.fish
Normal file
17
share/functions/__fish_whatis_current_token.fish
Normal file
@@ -0,0 +1,17 @@
|
||||
# This function is typically bound to Alt-W, it is used to list man page entries
|
||||
# for the command under the cursor.
|
||||
function __fish_whatis_current_token -d "Show man page entries related to the token under the cursor"
|
||||
set -l tok (commandline -pt)
|
||||
|
||||
if test -n "$tok[1]"
|
||||
printf "\n"
|
||||
whatis $tok[1]
|
||||
|
||||
set -l line_count (count (fish_prompt))
|
||||
for x in (seq 2 $line_count)
|
||||
printf "\n"
|
||||
end
|
||||
|
||||
commandline -f repaint
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user