├── .gitignore ├── README.md ├── install.sh └── uninstall.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # General 2 | .DS_Store 3 | .AppleDouble 4 | .LSOverride 5 | 6 | # Icon must end with two \r 7 | Icon 8 | 9 | # Thumbnails 10 | ._* 11 | 12 | # Files that might appear in the root of a volume 13 | .DocumentRevisions-V100 14 | .fseventsd 15 | .Spotlight-V100 16 | .TemporaryItems 17 | .Trashes 18 | .VolumeIcon.icns 19 | .com.apple.timemachine.donotpresent 20 | 21 | # Directories potentially created on remote AFP share 22 | .AppleDB 23 | .AppleDesktop 24 | Network Trash Folder 25 | Temporary Items 26 | .apdisk 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gcloud Shell ZSH 2 | 3 | ZSH with Antigen (Oh My ZSH) 4 | 5 | ```sh 6 | _______ __ __ _______ _______ ___ ___ 7 | | _ .----| .-----.--.--.--| | | _ | _ | Y | 8 | |. |___| __| | _ | | | _ | |___| | |___|. | | 9 | |. | |____|__|_____|_____|_____| / ___/|____ |. _ | 10 | |: ┴ | |: ┴ \|: ┴ |: | | 11 | |::.. . | |::.. . |::.. . |::.|:. | 12 | `-------’ `-------`-------`--- --- 13 | 14 | Feature rich Google Cloud Shell with ZSH 15 | 16 | Check for updates https://github.com/Andygol/gcloud-shell-zsh 17 | 18 | Use omz plugin enable to add couple of them 19 | ``` 20 | 21 | ## Install 22 | 23 | 1. Open default (bash) Google Cloud Shell 24 | 2. Copy, paste and run 25 | 26 | ```sh 27 | sh -c "$(curl -fsSL https://raw.githubusercontent.com/Andygol/gcloud-shell-zsh/main/install.sh)" 28 | ``` 29 | 30 | ### Included plugins 31 | 32 | #### 3rd party plugins installed via Antigen 33 | 34 | - `zsh-users/zsh-syntax-highlighting` 35 | - `zsh-users/zsh-autosuggestions` 36 | - `zsh-users/zsh-aliases-lsd` 37 | 38 | #### Oh My ZSH plugins 39 | 40 | To install Oh My ZSH plugins, use the command provided below 41 | 42 | ```sh 43 | omz plugin enable 44 | ``` 45 | 46 | ## Uninstall 47 | 48 | - `rm -rf ~/.antigen ~/.oh-my-zsh` 49 | - `rm -f ~/.zsh*` 50 | - `sudo apt remove --purge zsh -y` 51 | - `mv ~/.profile.pre-zsh ~/.profile` 52 | 53 | To uninstall ZSH along with Oh My ZSH and Antigen, use the command provided below 54 | 55 | ```sh 56 | sh -c "$(curl -fsSL https://raw.githubusercontent.com/Andygol/gcloud-shell-zsh/main/uninstall.sh)" 57 | ``` 58 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ANTIGEN=$HOME/.antigen 4 | 5 | banner() { 6 | local RC_FILE=$1 7 | 8 | echo -e "clear\n" >> $RC_FILE 9 | echo -e "echo ' _______ __ __ _______ _______ ___ ___ '" >> $RC_FILE 10 | echo -e "echo ' | _ .----| .-----.--.--.--| | | _ | _ | Y |'" >> $RC_FILE 11 | echo -e "echo ' |. |___| __| | _ | | | _ | |___| | |___|. | |'" >> $RC_FILE 12 | echo -e "echo ' |. | |____|__|_____|_____|_____| / ___/|____ |. _ |'" >> $RC_FILE 13 | echo -e "echo ' |: ┴ | |: ┴ \|: ┴ |: | |'" >> $RC_FILE 14 | echo -e "echo ' |::.. . | |::.. . |::.. . |::.|:. |'" >> $RC_FILE 15 | echo -e "echo ' \`-------’ \`-------\`-------\`--- ---’'" >> $RC_FILE 16 | echo -e "echo ' '" >> $RC_FILE 17 | echo -e "echo ' Feature rich Google Cloud Shell with ZSH '" >> $RC_FILE 18 | echo -e "echo ' '" >> $RC_FILE 19 | echo -e "echo ' Check for updates https://github.com/Andygol/gcloud-shell-zsh '" >> $RC_FILE 20 | echo -e "echo ' '" >> $RC_FILE 21 | echo -e "echo ' Use omz plugin enable to add couple of them '" >> $RC_FILE 22 | } 23 | 24 | install_package() { 25 | local package_name=$1 26 | local package_version=$2 27 | 28 | if ! command -v $package_name &> /dev/null; then 29 | echo "Installing $package_name..." 30 | if [ -z "$package_version" ]; then 31 | sudo apt install -y $package_name 32 | else 33 | sudo apt install -y $package_name=$package_version 34 | fi 35 | fi 36 | } 37 | 38 | is_exist() { 39 | local file_name=$1 40 | [ -f "$file_name" ] || [ -h "$file_name" ] 41 | return $? 42 | } 43 | 44 | install_antigen() { 45 | is_exist $ANTIGEN/antigen.zsh 46 | if [ $? -ne 0 ]; then 47 | echo "Installing antigen..." 48 | mkdir -p $ANTIGEN 49 | curl -L git.io/antigen > $ANTIGEN/antigen.zsh 50 | fi 51 | } 52 | 53 | install_omz() { 54 | is_exist $HOME/.oh-my-zsh/oh-my-zsh.sh 55 | if [ $? -ne 0 ]; then 56 | echo "Installing Oh My Zsh..." 57 | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended 58 | fi 59 | } 60 | 61 | configure_antigen() { 62 | is_exist $ANTIGEN/.antigen.sh 63 | if [ $? -ne 0 ]; then 64 | touch $ANTIGEN/.antigen.sh 65 | echo -e "Configuring .antigen.sh ...\n" 66 | 67 | echo -e \ 68 | "source $ANTIGEN/antigen.zsh \n\n\ 69 | \ 70 | # Syntax highlighting bundle. \n\ 71 | antigen bundle zsh-users/zsh-completions \n\ 72 | antigen bundle zsh-users/zsh-syntax-highlighting \n\ 73 | antigen bundle zsh-users/zsh-autosuggestions \n\ 74 | \ 75 | # Tell Antigen that you're done. \n\ 76 | antigen apply \n\n" >> $ANTIGEN/.antigen.sh 77 | 78 | banner "$ANTIGEN/.antigen.sh" 79 | 80 | fi 81 | } 82 | 83 | init_zsh() { 84 | 85 | echo -e "Install ZSH \n" 86 | install_package zsh 87 | 88 | if [ ! -f "$HOME/.zshrc" ]; then 89 | 90 | echo -e "~/.zshrc does not exist, it will be created... \n" 91 | 92 | if [ -f "$HOME/.bashrc" ] && [ -f "$HOME/.profile" ]; then 93 | 94 | echo "Backup ~/.profile" 95 | echo "Found ~/.bashrc and ~/.profile, backup ~/.profile to ~/.profile.pre-zsh" 96 | echo " " 97 | 98 | cp $HOME/.profile $HOME/.profile.pre-zsh 99 | 100 | echo -e "\n# Initializing zsh" >> $HOME/.profile 101 | echo 'sh -c "$(curl -fsSL https://raw.githubusercontent.com/Andygol/gcloud-shell-zsh/main/install.sh)"' >> $HOME/.profile 102 | fi 103 | 104 | echo -e "Antigen will be installed \n" 105 | install_antigen 106 | 107 | echo -e "Antigen is being configured \n" 108 | configure_antigen 109 | 110 | echo -e "Oh My ZSH will be installed \n" 111 | install_omz 112 | 113 | echo -e "Add Antigen to ~/.zshrc\n" 114 | sed -i '/source $ZSH\/oh-my-zsh.sh/a source $HOME\/.antigen\/.antigen.sh' ~/.zshrc 115 | fi 116 | 117 | exec zsh 118 | } 119 | 120 | init_zsh 121 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Function to print messages in a consistent way 4 | print_message() { 5 | echo -e "==> $1" 6 | } 7 | 8 | # Check if Zsh is installed 9 | if ! command -v zsh &> /dev/null; then 10 | print_message "Zsh is not installed\nThere's nothing to do" 11 | fi 12 | 13 | # Backup and remove files and folders 14 | print_message "Removing Antigen and Oh My Zsh..." 15 | rm -rf ~/.antigen ~/.oh-my-zsh 16 | rm -f ~/.zsh* ~/antigen.zsh 17 | 18 | # Uninstall Zsh 19 | print_message "Uninstalling Zsh..." 20 | sudo apt remove --purge zsh -y 21 | 22 | # Restore the previous version of the profile 23 | if [ -f "$HOME/.profile.pre-zsh" ]; then 24 | print_message "Restoring previous version of the profile..." 25 | mv ~/.profile.pre-zsh ~/.profile 26 | else 27 | print_message "No previous profile backup found." 28 | fi 29 | 30 | print_message "You have successfully removed Zsh and related configurations." 31 | 32 | # Pause for user confirmation 33 | read -p "Press Enter to continue..." 34 | --------------------------------------------------------------------------------