dotfiles/bin/giti
Smirnov Alexandr 633e8ad6cd Add zathura
2021-03-22 10:55:39 +02:00

42 lines
1 KiB
Bash
Executable file

#!/bin/sh
function add() {
echo $1 >> .gitignore
echo "[.gitignore] Successful add '$1'."
}
function del() {
if [ -f '.gitignore' ]; then
if [ "$(cat .gitignore|wc -l)" = "1" ]
then rm .gitignore
else sed -i "/$1/d" .gitignore
fi
else echo "[.gitignore] File not found."
fi
echo "[.gitignore] Successful del '$1'."
}
function edit() {
sed -in "s|$1|$2|g" .gitignore
}
function show() {
if [ -f '.gitignore' ]; then
if [ -f '/usr/bin/bat' ]
then bat .gitignore
else cat .gitignore
fi
else echo "[.gitignore] File not found."
fi
}
case "$1" in
add|a) shift; add "$@" ;;
del|d) shift; del "$@" ;;
mv) shift; edit "$@" ;;
show) shift; show ;;
help) echo "add|a - [file name] add to ignore."
echo "del|d - [file name] delete from ignore."
echo "mv - [old] [new] file name for rename."
echo "show - show ignore file." ;;
*) echo "Command is not valid. Type 'giti help' for help." ;;
esac