File: fish_commandline_append.fish

package info (click to toggle)
fish 4.2.1-3.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,976 kB
  • sloc: python: 6,972; javascript: 1,407; sh: 1,009; xml: 411; ansic: 230; objc: 78; makefile: 20
file content (15 lines) | stat: -rw-r--r-- 544 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function fish_commandline_append --description "Append the given string to the command-line, or remove the suffix if already there"
    if not commandline | string length -q
        commandline -r $history[1]
    end

    set -l escaped (string escape --style=regex -- $argv[1])
    set -l job (commandline -j | string collect)
    if set job (string replace -r -- $escaped\$ "" $job)
        set -l cursor (commandline -C)
        commandline -rj -- $job
        commandline -C $cursor
    else
        commandline -aj -- $argv[1]
    end
end