Skip to content

Commit

Permalink
fixed grammar and vague sentences using GPT
Browse files Browse the repository at this point in the history
  • Loading branch information
CXwudi committed Mar 13, 2024
1 parent 741b4a8 commit acd047d
Showing 1 changed file with 45 additions and 34 deletions.
79 changes: 45 additions & 34 deletions content/posts/2024/my-zsh-setup/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,46 +43,44 @@ This blog post is written based on the following resources:
1. [oh my zsh](https://github.com/ohmyzsh/ohmyzsh/wiki)
2. [powerlevel10k](https://github.com/romkatv/powerlevel10k#getting-started)

Make sure to check them out for more detailed information.
Feel free to check them out for more detailed information.

## Prerequisites

This guide works well for Linux (including WSL2), MacOS, and Windows [git-bash](https://git-scm.com/downloads).

{{< admonition type=tip title="What about Windows Powershell?" open=false >}}
Check out [oh-my-posh](https://ohmyposh.dev/) for a similar setup in Powershell. However, I won't cover it in this post.
Check out [oh-my-posh](https://ohmyposh.dev/) for a similar setup in Powershell. However, this post won't cover it.
{{< /admonition >}}

## Step 1: Install Necessary Fonts

Powerlevel10k works best with its own font called [_Meslo Nerd Font_](https://github.com/romkatv/powerlevel10k#manual-font-installation). Therefore, you have to install it on your OS first. Then for each shell/terminal program you used (VSCode, Intellij, Windows Terminal, iTerm2, just named a few...), you need to configure it to use these custom fonts.
Powerlevel10k works best with its own font called [_Meslo Nerd Font_](https://github.com/romkatv/powerlevel10k#manual-font-installation). Therefore, you need to install it on your OS first. Then, for each shell/terminal program you use (VSCode, Intellij, Windows Terminal, iTerm2, to name a few...), you need to configure it to use these custom fonts.

Fortunately, the [guidance](https://github.com/romkatv/powerlevel10k#manual-font-installation) from the powerlevel10k official GitHub repository covers the instructions of most of the popular terminals and shells on how to configure your terminal to use the Meslo Nerd Font.
Fortunately, the [guidance](https://github.com/romkatv/powerlevel10k#manual-font-installation) from the powerlevel10k official GitHub repository covers the instructions for most popular terminals and shells on how to configure your terminal to use the Meslo Nerd Font.

## Step 2: Install Necessary Dependencies

Oh My Zsh is an open-source, community-driven framework built on top of Zsh. The installation also requires other dependencies installed in your OS. So make sure you have the following installed:
Oh My Zsh is an open-source, community-driven framework built on top of Zsh. The installation also requires other dependencies to be installed on your OS. So, make sure you have the following installed:

- `zsh` (Z shell)
- `git` (version control system)
- `curl` or `wget` (to download the installation script)
<!-- - `python3` (Python 3.x) -->

For example, on the Debian-based system, you can install them with the following command:
For example, on a Debian-based system, you can install them with the following command:

```bash
sudo apt update
sudo apt install curl git zsh -y
```

For Windows Git Bash, installing Zsh can be challenging, you can checkout [this post](https://dominikrys.com/posts/zsh-in-git-bash-on-windows/#installing-zsh-in-git-bash) by Dominik Rys for how to install Zsh in Windows Git Bash

For Windows Git Bash, installing Zsh can be challenging. You can check out [this post](https://dominikrys.com/posts/zsh-in-git-bash-on-windows/#installing-zsh-in-git-bash) by Dominik Rys for how to install Zsh in Windows Git Bash.

## Step 3: Install Oh My Zsh, Powerlevel10k, and Plugins

At this point, you should have all the necessary dependencies installed. Now, run the following to install Oh My Zsh, Powerlevel10k, and some common plugins.

``` bash
```bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
Expand All @@ -93,14 +91,14 @@ git clone https://github.com/Pilaton/OhMyZsh-full-autoupdate ${ZSH_CUSTOM:-~/.oh

The above script does the following:

1. Install Oh My Zsh without triggering the interactive shell that asks for user to transfer the default shell to Zsh or not. We will transfer the default shell to Zsh manually later.
2. Install [Powerlevel10k](https://github.com/romkatv/powerlevel10k) theme
3. Install [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) plugin
- This plugin provides syntax highlighting for the shell, so that you will know if you have typed a command incorrectly before pressing enter.
4. Install [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) plugin
- This plugin suggests commands as you type based on history and completions, which can dramatically save your time on repeative tasks and commands.
5. Install [OhMyZsh-full-autoupdate](https://github.com/Pilaton/OhMyZsh-full-autoupdate) plugin
- Since everything is installed using git, it is crucial to keep them up-to-date. This plugin will automatically update Powerlevel10k and Oh My Zsh plugins by running `git pull` in the background. The update frequency depends on the Oh My Zsh settings, by default should be 13 days.
1. Install Oh My Zsh without triggering the interactive shell that asks the user to transfer the default shell to Zsh or not. We will transfer the default shell to Zsh manually later.
2. Install the [Powerlevel10k](https://github.com/romkatv/powerlevel10k) theme.
3. Install the [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) plugin.
- This plugin provides syntax highlighting for the shell, so you will know if you have typed a command incorrectly before pressing enter.
4. Install the [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) plugin.
- This plugin suggests commands as you type based on history and completions, which can dramatically save your time on repetitive tasks and commands.
5. Install the [OhMyZsh-full-autoupdate](https://github.com/Pilaton/OhMyZsh-full-autoupdate) plugin.
- Since everything is installed using git, it is crucial to keep them up-to-date. This plugin will automatically update Powerlevel10k and Oh My Zsh plugins by running `git pull` in the background. The update frequency depends on the Oh My Zsh settings, by default, it should be every 13 days.

## Step 4: Configuring `.zshrc` to use Powerlevel10k and Plugins

Expand All @@ -110,10 +108,10 @@ By default, Oh My Zsh will create a `.zshrc` file with a default theme and a sin

Open it with your favorite text editor like `nano` and change the following lines:

1. Change the theme from `ZSH_THEME="robbyrussell"` to `ZSH_THEME="powerlevel10k/powerlevel10k"`
1. Change the theme from `ZSH_THEME="robbyrussell"` to `ZSH_THEME="powerlevel10k/powerlevel10k"`.
2. Add more plugins to the `plugins` array, from `plugins=(git)` to:
```bash
plugins=(git aliases common-aliases zsh-syntax-highlighting zsh-autosuggestions ohmyzsh-full-autoupdate)`
plugins=(git aliases common-aliases zsh-syntax-highlighting zsh-autosuggestions ohmyzsh-full-autoupdate)
```

The above can be achieved by running two `sed` commands:
Expand All @@ -127,18 +125,18 @@ sed -i 's/plugins=(git)/plugins=(git aliases common-aliases zsh-syntax-highlight

Skip this step if you are setting up a new system.

If you are migrating from Bash to Zsh on your existing system, you should take some time to migrate your `.bashrc` and `.profile` to `.zshrc` and `.zprofile` respectively.
If you are migrating from Bash to Zsh on your existing system, you should take some time to migrate your `.bashrc` and `.profile` to `.zshrc` and `.zprofile`, respectively.

Unfortunately, there is no automatic way to do the migration. I also strongly discourage you from executing Zsh at the end of your `.bashrc` or `.profile` file, as it can cause problems for other scripts, applications or IDEs.
Unfortunately, there is no automatic way to do the migration. I also strongly discourage you from executing Zsh at the end of your `.bashrc` or `.profile` file, as it can cause problems for other scripts, applications, or IDEs.

However, some general things to consider to be migrated are:
However, some general things to consider for migration are:

- Scripts that 3rd party package managers like Homebrew, SDKMan, etc. have added to your `.bashrc` or `.profile`
- Custom environment variables
- Custom paths
- Custom aliases
- consider migrating to existing plugins in Oh My Zsh, checkout [`common-aliases`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/common-aliases) plugin and more in the [official documentation](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins)
- For example, if you use docker, consider adding [`docker`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/docker) and `docker-compose` aliases to the `plugins` array in `.zshrc`
- Scripts that third-party package managers like Homebrew, SDKMan, etc. have added to your `.bashrc` or `.profile`.
- Custom environment variables.
- Custom paths.
- Custom aliases.
- Consider migrating to existing plugins in Oh My Zsh. Check out the [`common-aliases`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/common-aliases) plugin and more in the [official documentation](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins).
- For example, if you use Docker, consider adding the [`docker`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/docker) and `docker-compose` aliases to the `plugins` array in `.zshrc`.

## Step 6: Set Zsh as the Default Shell

Expand All @@ -148,17 +146,30 @@ Finally, set Zsh as the default shell by running the following command:
chsh -s $(which zsh)
```

For Windows git-bash,
For Windows Git Bash, as far as I know, there is no official way to set another shell as the default shell. However, you can run `zsh` manually every time you open the terminal. Or append this script to the end of your `.bashrc` file to automatically run Zsh when you open the terminal (Yeah, it goes against what I said in Step 5, but it's the best we can do for now 😕):
```bash
# At the end, switch to zsh
if [[ -t 1 && -x /usr/bin/zsh ]]; then
export SHELL=$(which zsh)
if [[ -o login ]]
then
exec zsh -l
else
exec zsh
fi
fi
```
## Step 7: Bootstrapping Powerlevel10k
After you have set Zsh as the default shell, starting a new terminal session will immediately bring you to the Powerlevel10k configuration wizard. You can also run `p10k configure` at any time to run the wizard again. The wizard will guide you through the process of configuring Powerlevel10k to your liking.
{{< figure src="power10k-configuration-wizard.gif" caption="Screen recording of the Powerlevel10k Configuration Wizard (from official GitHub repo)" alt="Image Alt Text" >}}
{{< figure src="power10k-configuration-wizard.gif" caption="Screen recording of the Powerlevel10k Configuration Wizard (from the official GitHub repo)" alt="Image Alt Text" >}}
Going through the wizard can be time-consuming. So here I prepared a snippet of answers that you can use to quickly configure Powerlevel10k. Just copy and paste it when you just started the `p10k configure` wizard:
Going through the wizard can be time-consuming. So here, I have prepared a snippet of answers that you can use to quickly configure Powerlevel10k. Just copy and paste it when you have just started the `p10k configure` wizard:
``` bash
```bash
y
y
y
Expand All @@ -171,7 +182,7 @@ y
1
2
2
3 # change this to 1 if you want to the use the style shown in the featured image of this post
3 # change this to 1 if you want to use the style shown in the featured image of this post
2
2
2
Expand Down

0 comments on commit acd047d

Please sign in to comment.