make rc function more useful

This commit is contained in:
James Dixon 2020-07-20 22:30:31 -04:00
parent fdc87a717c
commit b9cf8fec36

View File

@ -157,26 +157,83 @@ bkup() {
} }
# easy diff rc files in home and in dotfile repo # easy diff rc files in home and in dotfile repo
rcdiff() { rc() {
if [ "$#" -lt 1 ]; then error_1() {
echo "Please specify rc to diff" echo "Please specify rc command: [diff] [up] [down]"
fi echo "and a valid dotfile: [vim] [bash] [git] [tmux]"
return 1
}
if [ "$1" == "vim" ]; then error_2() {
vimdiff "$HOME/.vim/vimrc" "$DF/vim/vimrc" echo "Please specify a valid dotfile: [vim] [bash] [git] [tmux]"
fi return 2
}
if [ "$1" == "bash" ]; then case "$1" in
vimdiff "$HOME/.bashrc" "$DF/bash/bashrc" "diff"|"di")
fi case "$2" in
"vim")
vimdiff "$HOME/.vim/vimrc" "$DF/vim/vimrc" ;;
"bash")
vimdiff "$HOME/.bashrc" "$DF/bash/bashrc" ;;
"git")
vimdiff "$HOME/.gitconfig" "$DF/git/gitconfig" ;;
"tmux")
vimdiff "$HOME/.tmux.conf" "$DF/tmux/tmux.conf" ;;
*)
error_2
esac
return;;
if [ "$1" == "git" ]; then "edit"|"e")
vimdiff "$HOME/.gitconfig" "$DF/git/gitconfig" case "$2" in
fi "vim")
vim "$HOME/.vim/vimrc" ;;
"bash")
vim "$HOME/.bashrc" ;;
"git")
vim "$HOME/.gitconfig" ;;
"tmux")
vim "$HOME/.tmux.conf" ;;
*)
error_2
esac
return;;
if [ "$1" == "tmux" ]; then "up"|"u")
vimdiff "$HOME/.tmux.conf" "$DF/tmux/tmux.conf" case "$2" in
fi "vim")
cp "$HOME/.vim/vimrc" "$DF/vim/vimrc" ;;
"bash")
cp "$HOME/.bashrc" "$DF/bash/bashrc" ;;
"git")
cp "$HOME/.gitconfig" "$DF/git/gitconfig" ;;
"tmux")
cp "$HOME/.tmux.conf" "$DF/tmux/tmux.conf" ;;
*)
error_2
esac
(cd "$DF" || return) && git diff
return;;
"down"|"d")
case "$2" in
"vim")
cp "$DF/vim/vimrc" "$HOME/.vim/vimrc" ;;
"bash")
cp "$DF/bash/bashrc" "$HOME/.bashrc" ;;
"git")
cp "$DF/git/gitconfig" "$HOME/.gitconfig" ;;
"tmux")
cp "$DF/tmux/tmux.conf" "$HOME/.tmux.conf" ;;
*)
error_2
esac
return;;
*)
error_1
esac
} }
# git # git