git_write_keyword.fish 395 B

123456789101112
  1. function git_write_keyword --description 'Write git in terminal prompt'
  2. set -l cmd (commandline -po)
  3. set -l cursor (commandline -C)
  4. if test "$cmd[1]" != git
  5. commandline -C 0
  6. commandline -i "git "
  7. commandline -C (math $cursor + 4)
  8. else
  9. commandline -r (string sub --start=5 (commandline -p))
  10. commandline -C -- (math $cursor - 4)
  11. end
  12. end