12345678910111213141516171819202122232425 |
- function git_write_keyword --description 'Write git in terminal prompt'
- set -l cmd (commandline -po)
- set -l cursor (commandline -C)
- set -l keywords 'git commit' 'git add' 'git stash'
- if test "$cmd[1]" != 'git'
- commandline -C 0
- commandline -i 'git '
- commandline -C (math $cursor + 4)
- else if test (commandline -p) = 'git '
- commandline -r $keywords[1]
- commandline -C (string length $keywords[1])
- else if test (commandline -p) = $keywords[1]
- commandline -r $keywords[2]
- commandline -C (string length $keywords[2])
- else if test (commandline -p) = $keywords[2]
- commandline -r $keywords[3]
- commandline -C (string length $keywords[3])
- else if test (commandline -p) = $keywords[3]
- commandline -r ''
- commandline -C 0
- else
- commandline -r (string sub --start=5 (commandline -p))
- commandline -C -- (math $cursor - 4)
- end
- end
|