zshgcloud

leave gcloud project in terminal


How can I leave my current gcloud project via the cloud cli so I can revert back to my normal terminal?

15:40:08 in ~ using ☁️  default/192085439987

I just want to be using

15:40:08 in ~

I have managed to swap between projects using

gcloud config set project <project id>

But can't seem to leave anything


Solution

  • When you use the gcloud command the terminal keeps the same properties, if any it could change the shell you're using, in that case to return back to your previous shell you can just type exit which normally would take you out of the last shell.

    Here are some detailed instructions to go back the old shell or prompt depending on what changed on your side:

    1. Determine the shell you're using before starting the gcloud command by typing echo $SHELL, this will provide the name of the shell which could be something like /bin/bash for bash or /bin/zsh for zshell.

    2. Once that you have finished using gcloud, type $SHELL again and determine if the shell you're using now changed. If it did changed, normally with an exit command you would leave the old shell, if it doesn't work you can type the whole route of the binary and you will switch to it, for example type /bin/zsh to go back to zsh

    3. If the prompt also changed, you can go back to the default one by executing . ./.profile, source ~/.zshrc for zsh or source ~/.bashrc for bash

    If the prompt is changed since the beginning (before executing the gcloud command) then you probably have to edit your .profile or .zshrc files to set them as you like to have them, more information about it, can be found here