BASH CASE FLOW

Added bash case flow

- added two mode single installation and global installation
- tested all cases [PASS]
This commit is contained in:
infidel 2022-03-24 00:56:24 +07:00
parent a776d9ceac
commit 24b5d58262
2 changed files with 95 additions and 11 deletions

4
.vimrc
View File

@ -11,6 +11,8 @@ Plug 'kaicataldo/material.vim', { 'branch': 'main' }
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Intelisense Plug 'neoclide/coc.nvim', {'branch': 'release'} " Intelisense
Plug 'sheerun/vim-polyglot' Plug 'sheerun/vim-polyglot'
Plug 'lifepillar/vim-gruvbox8' Plug 'lifepillar/vim-gruvbox8'
Plug 'junegunn/vim-easy-align'
Plug 'rakr/vim-two-firewatch'
call plug#end() call plug#end()
@ -57,7 +59,7 @@ augroup vimrc-remember-cursor-position
augroup END augroup END
set background=dark set background=dark
colo default colo two-firewatch
map <C-k><C-k> :NERDTreeToggle<cr> " Use Ctrl-P to open the fuzzy file opener map <C-k><C-k> :NERDTreeToggle<cr> " Use Ctrl-P to open the fuzzy file opener
nnoremap <C-p> :Files<cr> nnoremap <C-p> :Files<cr>

View File

@ -4,15 +4,97 @@
# cp -r ./.vim/ /home/$(whoami)/ # cp -r ./.vim/ /home/$(whoami)/
# cp -r ./.tmux.conf /home/$(whoami)/ # cp -r ./.tmux.conf /home/$(whoami)/
echo "VIM Conf" user_guide () {
ln -sf $(pwd)/.vimrc /home/$(whoami)/ echo
ln -sf $(pwd)/.vim/ /home/$(whoami)/ echo "Usage: $0 [options]"
vim -c 'PlugInstall' echo
echo "Options:"
echo " -i : Install for Single User [user,root]"
echo " -a : Install for all user"
echo "TMUX Conf"
ln -sf $(pwd)/.vimrc /home/$(whoami)/
ln -sf $(pwd)/.tmux.conf /home/$(whoami)/
echo "TMUX Plugin" }
mkdir -p "/home/$(whoami)/.tmux/plugins"
[ -d "/home/$(whoami)/.tmux/plugins/tpm" ] || git clone https://github.com/tmux-plugins/tpm /home/$(whoami)/.tmux/plugins/tpm user_install () {
echo "VIM Conf"
ln -sf $(pwd)/.vimrc /home/$(whoami)/
ln -sf $(pwd)/.vim/ /home/$(whoami)/
vim -c 'PlugInstall'
echo "TMUX Conf"
ln -sf $(pwd)/.vimrc /home/$(whoami)/
ln -sf $(pwd)/.tmux.conf /home/$(whoami)/
echo "TMUX Plugin"
mkdir -p "/home/$(whoami)/.tmux/plugins"
[ -d "/home/$(whoami)/.tmux/plugins/tpm" ] || git clone https://github.com/tmux-plugins/tpm /home/$(whoami)/.tmux/plugins/tpm
}
root_install () {
# sudo su
echo "VIM Conf"
sudo ln -sf $(pwd)/.vimrc /root/
sudo ln -sf $(pwd)/.vim/ /root/
vim -c 'PlugInstall'
echo "TMUX Conf"
sudo ln -sf $(pwd)/.vimrc /root/
sudo ln -sf $(pwd)/.tmux.conf /root/
echo "TMUX Plugin"
sudo mkdir -p "/root/.tmux/plugins"
[ -d "/root/.tmux/plugins/tpm" ] || sudo git clone https://github.com/tmux-plugins/tpm /root/.tmux/plugins/tpm
}
# echo "What : $#"
if [ $# -lt 1 ]
then
user_guide # Call user guide
exit
fi
# echo "case $1"
case "$1" in
-i) echo "Installing For Single User "
if [ $# -lt 2 ]
then
echo "Error Syntax"
user_guide # Call user guide
exit
fi
case "$2" in
user) echo "USER Installation"
echo "Case $2"
user_install # Call User install function
;;
root) echo "ROOT Installation"
echo "Case $2"
root_install # Call User install function
;;
*)
echo "Error Syntax"
user_guide # Call user guide
;;
esac
;;
-a) echo "Installing...."
echo "Case Global"
if [ $# -gt 1 ]
then
user_guide # Call user guide
exit
fi
user_install # Call User install function
root_install # Call User install function
;;
*)
echo "Error Syntax"
user_guide # Call user guide
;;
esac