git_write_keyword.fish 707 B

123456789101112131415161718192021
  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 if test (commandline -p) = 'git '
  9. commandline -r 'git commit -a'
  10. commandline -C 13
  11. else if test (commandline -p) = 'git commit -a'
  12. commandline -r 'git add .'
  13. commandline -C 9
  14. else if test (commandline -p) = 'git add .'
  15. commandline -r ''
  16. commandline -C 0
  17. else
  18. commandline -r (string sub --start=5 (commandline -p))
  19. commandline -C -- (math $cursor - 4)
  20. end
  21. end