Fix colors.

This commit is contained in:
Ceda EI 2019-05-12 14:59:30 +05:30
parent 85f5e482a0
commit bb91f1a4c9
1 changed files with 17 additions and 13 deletions

View File

@ -10,31 +10,35 @@ function find_package_manager() {
function install_package() { function install_package() {
package_manager=$(find_package_manager) package_manager=$(find_package_manager)
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo -e "\033[38;5;1mCould not find package manager" >&2 echo -e "\033[38;5;1mCould not find package manager\033[0;5;0m" >&2
exit return 1
fi fi
case $package_manager in case $package_manager in
pacman) pacman)
sudo pacman -S $* sudo pacman -S $*
return $?
;; ;;
apt-get) apt-get)
sudo apt-get install $* sudo apt-get install $*
return $?
;; ;;
apk) apk)
sudo apk add $* sudo apk add $*
return $?
;; ;;
esac esac
return 2
} }
function check_and_install() { function check_and_install() {
if hash $1 &> /dev/null; then if hash $1 &> /dev/null; then
echo -e "\033[38;5;2m$1 is already installed." echo -e "\033[38;5;2m$1 is already installed.\033[0;5;0m"
else else
echo -e "\033[38;5;2mInstalling $1." echo -e "\033[38;5;2mInstalling $1.\033[0;5;0m"
if install_package $1; then if install_package $1; then
echo -e "\033[38;5;2m$1 installed." echo -e "\033[38;5;2m$1 installed.\033[0;5;0m"
else else
echo -e "\033[38;5;1mInstalling $1 failed." >&2 echo -e "\033[38;5;1mInstalling $1 failed.\033[0;5;0m" >&2
fi fi
fi fi
} }
@ -53,8 +57,8 @@ fi
bd=$(dirname $0) bd=$(dirname $0)
cd "$bd" cd "$bd"
echo -e "\033[38;5;2mBase Directory: $(pwd)\n" echo -e "\033[38;5;2mBase Directory: $(pwd)\n\033[0;5;0m"
echo -e "\033[38;5;2mInstalling packages\n" echo -e "\033[38;5;2mInstalling packages\n\033[0;5;0m"
check_and_install stow check_and_install stow
check_and_install bash check_and_install bash
@ -63,7 +67,7 @@ check_and_install vim
check_and_install curl check_and_install curl
check_and_install git check_and_install git
echo -e "\n\033[38;5;2mStowing config\n" echo -e "\n\033[38;5;2mStowing config\033[0;5;0m\n"
mv ~/.bashrc{,.old} &> /dev/null mv ~/.bashrc{,.old} &> /dev/null
stow_cfg bash stow_cfg bash
@ -76,18 +80,18 @@ mv ~/.vimrc{,.old} &> /dev/null
mv ~/.vim{,.old} &> /dev/null mv ~/.vim{,.old} &> /dev/null
stow_cfg vim stow_cfg vim
echo -e "\n\033[38;5;2mSetting up wish\n" echo -e "\n\033[38;5;2mSetting up wish\033[0;5;0m\n"
mkdir -p ~/.config/ mkdir -p ~/.config/
git clone https://gitlab.com/ceda_ei/wish.git ~/.config/wish git clone https://gitlab.com/ceda_ei/wish.git ~/.config/wish
echo -e "\n\033[38;5;2mSetting up tmux plugins\n" echo -e "\n\033[38;5;2mSetting up tmux plugins\033[0;5;0m\n"
mkdir -p ~/.tmux/plugins/ mkdir -p ~/.tmux/plugins/
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
~/.tmux/plugins/tpm/bin/install_plugins ~/.tmux/plugins/tpm/bin/install_plugins
echo -e "\n\033[38;5;2mSetting up vim plugins\n" echo -e "\n\033[38;5;2mSetting up vim plugins\033[0;5;0m\n"
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
vim +PlugInstall +qall vim +PlugInstall +qall
echo -e "\n\033[38;5;2mComplete\n" echo -e "\n\033[38;5;2mComplete\033[0;5;0m\n"