diff --git a/install.sh b/install.sh index 346cdca..f9f8baa 100755 --- a/install.sh +++ b/install.sh @@ -192,11 +192,49 @@ set_up_vim() { setup_vimplug } +# zoxide requres extra shell configuration setup +set_up_zoxide_shell_config() { + local source_cmd_zsh='eval "$(zoxide init zsh)"' + local source_cmd_bash='eval "$(zoxide init bash)"' + if program_exists "zsh"; then + # if not already contain source command + file_contains "$source_cmd_zsh" ~/.zshrc + status_code=$? + if [ "$status_code" != '0' ]; then + echo "Install zoxide source command ($source_cmd_zsh) for zsh shell?('y' install; 'q' quit the scrip)" + read -r respond + if [ "$respond" = "y" ] || [ "$respond" = "yes" ]; then + echo "$source_cmd_zsh" >> $HOME/.zshrc + elif [ "$respond" = "q" ]; then + exit 0 + fi + success "add ($source_cmd_zsh) to zsh" + fi + fi + + if program_exists "bash"; then + # if not already contain source command + file_contains "$source_cmd_bash" ~/.bashrc + status_code=$? + if [ "$status_code" != '0' ]; then + echo "Install zoxide source command ($source_cmd_bash) for bash shell?('y' install; 'q' quit the scrip)" + read -r respond + if [ "$respond" = "y" ] || [ "$respond" = "yes" ]; then + echo "$source_cmd_bash" >> $HOME/.bashrc + elif [ "$respond" = "q" ]; then + exit 0 + fi + success "add ($source_cmd_bash) to bash" + fi + fi +} + set_up_zoxide() { # https://github.com/ajeetdsouza/zoxide if program_exists "zoxide"; then success "zoxide is already installed" + set_up_zoxide_shell_config return 0 fi @@ -206,40 +244,7 @@ set_up_zoxide() { program_must_exist "curl" # This will install zoxide into ~/.local curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash - - local source_cmd_zsh='eval "$(zoxide init zsh)"' - local source_cmd_bash='eval "$(zoxide init bash)"' - if program_exists "zsh"; then - # if not already contain source command - file_contains "$source_cmd_zsh" ~/.zshrc - status_code=$? - if [ "$status_code" != '0' ]; then - echo "Install zoxide source command ($source_cmd_zsh) for zsh shell?('y' install; 'q' quit the scrip)" - read -r respond - if [ "$respond" = "y" ] || [ "$respond" = "yes" ]; then - echo "$source_cmd_zsh" >> $HOME/.zshrc - elif [ "$respond" = "q" ]; then - exit 0 - fi - success "add ($source_cmd_zsh) to zsh" - fi - fi - - if program_exists "bash"; then - # if not already contain source command - file_contains "$source_cmd_bash" ~/.bashrc - status_code=$? - if [ "$status_code" != '0' ]; then - echo "Install zoxide source command ($source_cmd_bash) for bash shell?('y' install; 'q' quit the scrip)" - read -r respond - if [ "$respond" = "y" ] || [ "$respond" = "yes" ]; then - echo "$source_cmd_bash" >> $HOME/.bashrc - elif [ "$respond" = "q" ]; then - exit 0 - fi - success "add ($source_cmd_bash) to bash" - fi - fi + set_up_zoxide_shell_config elif [ "$respond" = "q" ]; then exit 0