You likely heard of or currently use oh-my-zsh for your terminal on Linux or Mac, or WSL on Windows. It might also be possible to have heard of or currently use oh-my-posh for your PowerShell. Azure offers Azure Cloud Shell service, which uses both Bash Shell and PowerShell by default. Therefore, if you want either oh-my-zsh or oh-my-posh, or both, you should configure it by yourself.
Throughout this post, I'm going to show how to configure your shell environment for both.
This GitHub repository provides the working shell script source for your reference.
justinyoo / oh-my-azure-cloud-shell
This provides an OPINIONATED collection of scripts to set up oh-my-zsh and oh-my-posh to your Azure Cloud Shell environment
Oh My Azure Cloud Shell
This provides an OPINIONATED collection of scripts to set up oh-my-zsh and oh-my-posh to your Azure Cloud Shell environment.
Getting Started
For oh-my-zsh
If you want to apply oh-my-zsh to your Azure Cloud Shell environment, follow the steps below:
Open your Azure Cloud Shell.
Make sure you are in the bash prompt. If you are in the PowerShell prompt, enter
bash
to switch the prompt.Clone this repository to your Azure Cloud Shell.
git clone https://github.com/justinyoo/oh-my-azure-cloud-shell.git ~/oh-my-azure-cloud-shell
Run the following commands and follow the instruction on the screen.
~/oh-my-azure-cloud-shell/install.sh
The command above will install the Spaceship theme by default. If you prefer the Powerlevel10k theme, run the following command:
# Turn on the clock feature ~/oh-my-azure-cloud-shell/install.sh -t p10k -c # Turn off the clock feature ~/oh-my-azure-cloud-shell/install.sh -t p10kRestart your Azure Cloud Shell.
If you want to turn…
For oh-my-zsh
Let's configure oh-my-zsh on your Azure Cloud Shell. Make sure that you see the Bash Shell prompt. If not, enter the bash
command to switch your prompt to Bash.
-
Install oh-my-zsh.
-
Install plug-ins for oh-my-zsh. Although there are many good plug-ins, this post will install the three popular ones – zsh-completions, zsh-syntax-highlighting and zsh-autosuggestions. If you want more plug-ins, follow the steps below.
-
Install themes for oh-my-zsh. It's totally up to you which theme you're going to pick, but this post chooses either Spaceship or Powerlevel10k.
-
If you choose the Powerlevel10k theme, run the following command for further configuration.
-
As mentioned above, Azure Cloud Shell uses Bash Shell by default. Unfortunately, you can't run the
chsh -s $(which zsh)
command becausesudo
is not allowed. Therefore, update your.bashrc
like below, as a workaround. Once everything so far is done, restart Azure Cloud Shell. Alternatively, run the command,
source .bashrc
. Then, you will have the oh-my-zsh applied shell prompt.-
If you want to run all steps above in just one command, run the following:
-
If you are with the Powerlevel10k theme and want to turn on or off the current time, run the following script:
Now, your Azure Cloud Shell starts using oh-my-zsh.
For oh-my-posh
Let's configure oh-my-posh on your Azure Cloud Shell this time. Make sure that you see the PowerShell prompt. If not, enter the pwsh
command to switch your prompt to PowerShell.
-
Install oh-my-posh.
-
Install themes for oh-my-posh. Again, it's totally up to you which theme you're going to pick, but this post chooses either Spaceship or Powerlevel10k - Rainbow.
-
Install plug-ins for oh-my-posh, like Terminal Icons.
-
Create the
$PROFILE
file to run when initiating a PowerShell session. -
Run the following command to reload
$PROFILE
. -
If you want to run all steps above in just one command, run the following:
-
If you are with the Powerlevel10k - Rainbow theme and want to turn on or off the current time, run the following script:
Now, your Azure Cloud Shell starts using oh-my-zsh.
So far, I've walked through how to configure either oh-my-zsh or oh-my-posh, or both. With both configurations, you will be able to extend your local shell scripting experiences to Azure Cloud Shell.
Top comments (0)