fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerPrepare to not localize private function descriptionsd835c5252

master
1.0 KiB21 linesraw
1# localization: tier1
2#
3# This is meant to be bound to key sequences such as \e#. It provides a simple way to quickly
4# comment/uncomment the current command. This is something introduced by the Korn shell (ksh) in
5# 1993. It allows you to capture a command in the shell history without executing it. Then
6# retrieving the command from the shell history and removing the comment chars.
7#
8# This deliberately does not execute the command when removing the comment characters to give you an
9# opportunity to modify the command. Also if the commandline is empty, the most recently commented
10# out history item is uncommented and presented.
11
12function __fish_toggle_comment_commandline --description 'Comment/uncomment the current command'
13    set -l cmdlines (commandline -b)
14    if test -z "$cmdlines"
15        set cmdlines (history search -p "#" --max=1)
16    end
17    set -l cmdlines (printf '%s\n' '#'$cmdlines | string replace -r '^##' '')
18    commandline -r $cmdlines
19    string match -q '#*' $cmdlines[1]
20    and commandline -f execute
21end