all repos

dotfiles @ 246dc34

i use rach linux btw

dotfiles/bin/giti (view raw)

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