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