Smirnov Alexandr
Smirnov Alexandr
ss2316544@gmail.com Update bin/giti, polybar(for bspwm), vscode, 5 years ago
ss2316544@gmail.com Update bin/giti, polybar(for bspwm), vscode, 5 years ago
| 1 | #!/bin/sh |
| 2 | function add() { |
| 3 | echo $1 >> .gitignore |
| 4 | echo "[.gitignore] Successful add '$1'." |
| 5 | } |
| 6 | function del() { |
| 7 | if [ -f '.gitignore' ]; then |
| 8 | if [ "$(cat .gitignore|wc -l)" = "1" ] |
| 9 | then rm .gitignore |
| 10 | else sed -i "/$1/d" .gitignore |
| 11 | fi |
| 12 | else echo "[.gitignore] File not found." |
| 13 | fi |
| 14 | echo "[.gitignore] Successful del '$1'." |
| 15 | } |
| 16 | function edit() { |
| 17 | sed -in "s|$1|$2|g" .gitignore |
| 18 | } |
| 19 | function show() { |
| 20 | if [ -f '.gitignore' ]; then |
| 21 | if [ -f '/usr/bin/bat' ] |
| 22 | then bat .gitignore |
| 23 | else cat .gitignore |
| 24 | fi |
| 25 | else echo "[.gitignore] File not found." |
| 26 | fi |
| 27 | } |
| 28 | |
| 29 | case "$1" in |
| 30 | add|a) shift; add "$@" ;; |
| 31 | del|d) shift; del "$@" ;; |
| 32 | mv) shift; edit "$@" ;; |
| 33 | show) shift; show ;; |
| 34 | help) echo "add|a - [file name] add to ignore." |
| 35 | echo "del|d - [file name] delete from ignore." |
| 36 | echo "mv - [old] [new] file name for rename." |
| 37 | echo "show - show ignore file." |
| 38 | ;; |
| 39 | *) echo "Command is not valid. Type 'giti help' for help." ;; |
| 40 | esac |