mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 09:23:28 +08:00
Uncomment most recent comment if commandline is empty when using toggle comment binding (#7137)
* functions/__fish_toggle_comment_commandline: Uncomment most recent comment if commandline is empty * Refactor variable setting in functions/__fish_toggle_comment_commandline.fish * Update changelog regarding toggle comment binding
This commit is contained in:
parent
d0c1f2a2cc
commit
2fd78fd5c2
|
@ -94,6 +94,8 @@ New or improved bindings
|
|||
- ``__fish_prepend_sudo`` (Alt-S) now toggles a ``sudo`` prefix (#7012).
|
||||
- ``__fish_prepend_sudo`` (Alt-S) now uses the previous commandline if the current one is empty,
|
||||
to simplify rerunning the previous command with ``sudo`` (#7079).
|
||||
- ``__fish_toggle_comment_commandline`` (Alt-#) now uncomments and presents the last comment
|
||||
from history if the commandline is empty (#7137).
|
||||
|
||||
Improved prompts
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
# retrieving the command from the shell history and removing the comment chars.
|
||||
#
|
||||
# This deliberately does not execute the command when removing the comment characters to give you an
|
||||
# opportunity to modify the command.
|
||||
# opportunity to modify the command. Also if the commandline is empty, the most recently commented
|
||||
# out history item is uncommented and presented.
|
||||
|
||||
function __fish_toggle_comment_commandline --description 'Comment/uncomment the current command'
|
||||
set -l cmdlines (commandline -b)
|
||||
if test "$cmdlines" = ""
|
||||
return
|
||||
history search -p "#" -z | read -z cmdlines
|
||||
end
|
||||
set -l cmdlines (printf '%s\n' '#'$cmdlines | string replace -r '^##' '')
|
||||
commandline -r $cmdlines
|
||||
|
|
Loading…
Reference in New Issue
Block a user