Revise blog post
This commit is contained in:
parent
f85c29c2d2
commit
d8bd99e013
1 changed files with 21 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
|
||||
date: 2025-06-04
|
||||
date: 2025-06-05
|
||||
title: zsh and GNU stow
|
||||
tags:
|
||||
|
||||
|
@ -97,19 +97,20 @@ always available so I just include it in my dotfiles repository.
|
|||
but with some different features that are interesting. It's worth nothing that I fully intend on using `bash`
|
||||
for scripting since it is far more ubiquitous than `zsh` and I am more familiar with it and its quirks.
|
||||
I will also note that zsh is NOT a [POSIX shell](https://en.wikipedia.org/wiki/POSIX);
|
||||
this is a common complaint that I see. Personally, I think I am okay with this since I
|
||||
this is a common complaint that I see. Personally, I am okay with this since I
|
||||
haven't run into any issues thus far and `zsh` is good enough to be the default shell in popular
|
||||
operating systems, including macOS and TrueNAS.
|
||||
|
||||
There are a couple reasons I decided to try `zsh`, the first being tab completion which
|
||||
I find helpful when completing a path or command where there are only a couple options to tab through.
|
||||
The other reasons I wanted to experiment with `zsh` are a bit more complex.
|
||||
I also wanted to try out some of the plugins and the configuration, which I find much easier to work with,
|
||||
compared to `bashrc`.
|
||||
|
||||
### RC Files
|
||||
|
||||
[Run Commands files](https://en.wikipedia.org/wiki/RUNCOM) are basically files that
|
||||
are executed when a program starts. I
|
||||
[previously detailed my .bashrc file](https://blog.mcknight.tech/2024/03/27/Shell-Customizations/#BASH-Configuration),
|
||||
[previously detailed my `.bashrc` file](https://blog.mcknight.tech/2024/03/27/Shell-Customizations/#BASH-Configuration),
|
||||
which is executed whenever I open a new `bash` shell.
|
||||
I wanted to experiment with `zsh` configuration because it feels a little more modern
|
||||
and powerful to me compared to `bash`. For example, my `bash` shell prompt looks like:
|
||||
|
@ -178,34 +179,35 @@ function precmd {
|
|||
PS2="%F$chrome_color└%F{cyan}>%F{white} "
|
||||
```
|
||||
|
||||
I find the `zsh` version to be much more readable and easier to modify since I have a
|
||||
I find the `zsh` version to be much more readable and easier to modify, since I have a
|
||||
method to generate the prompt instead of a single variable to cram everything into.
|
||||
I believe I have these two prompts looking identical in all cases and it only took me
|
||||
about an hour to get my `zshrc` working identically to my `bashrc`; this included
|
||||
moving some refactoring from `.bashrc` into `.bash_aliases` and `.profile`. I also
|
||||
some refactoring from `.bashrc` into `.bash_aliases` and `.profile`. I also
|
||||
made sure `.profile` is always sourced in `bash` and `zsh` shells to avoid duplicating
|
||||
code in rc files. I considered using a common `aliases` file, but decided against it since
|
||||
code in those rc files. I considered using a common `aliases` file, but decided against it since
|
||||
I use different aliases for different shells (i.e. `sudosu` is shell-specific).
|
||||
|
||||
### `zsh` Plugins
|
||||
|
||||
Another interesting feature of `zsh` is that it supports plugins.
|
||||
Now just like with Neovim, there are a number of different plugin managers that can be
|
||||
Now, just like with Neovim, there are a number of different plugin managers that can be
|
||||
used with `zsh`. I don't know if there is a "best" choice, but after some light reading
|
||||
on the popular options I could fine and some [LLM summary comparisons](https://search.brave.com/search?q=zinit+vs+omz&source=desktop&summary=1&conversation=f5495011020a89faf13bf1),
|
||||
up on the popular options I could find and some [LLM summary comparisons](https://search.brave.com/search?q=zinit+vs+omz&source=desktop&summary=1&conversation=f5495011020a89faf13bf1),
|
||||
I settled on [Zinit](https://github.com/zdharma-continuum/zinit) as a lightweight and
|
||||
apparently maintained option.
|
||||
|
||||
#### OMZ extract
|
||||
|
||||
This convenience command lets me extract files without having to remember the syntax for
|
||||
extracting `.tar.xz`, `.zip`, `.tar.gz`, etc. A simple `extract <file>`
|
||||
extracting `.tar.xz`, `.zip`, `.tar.gz`, etc. A simple `extract <file>` is much easier
|
||||
to remember than the specific commands for each compression algorithm.
|
||||
|
||||
#### OMZ colored-man-pages
|
||||
|
||||
This adds some color to man pages which I think makes it a little easier to skim to find
|
||||
CLI args and section headers. Its not the *best* IMO, but something is better than nothing
|
||||
here when trying to skim through what can be pretty dense documentation.
|
||||
when trying to skim through what can be pretty dense documentation.
|
||||
|
||||
#### OMZ encode64
|
||||
|
||||
|
@ -224,11 +226,12 @@ less commonly used flags.
|
|||
The Oh My Zsh sudo plugin adds a convenience keybind (`esc`+`esc`) to prepend `sudo` to
|
||||
the current command or the previous command if the input is empty. I find this to be
|
||||
convenient as it is fairly common to re-run the previous command with elevated privileges
|
||||
or to prepend `sudo` if I forgot to start with that.
|
||||
or to prepend `sudo` if I forgot to start with that (saving 5 keystrokes compared to
|
||||
`sudo !!`)
|
||||
|
||||
#### zsh-autosuggestions
|
||||
|
||||
This plugin works much like suggestions in an IDE, providing a suggested command completion
|
||||
This plugin feels much like suggestions in an IDE, providing a suggested command completion
|
||||
that can be filled in with a bound key (I am using `Shift`+`Tab`).
|
||||
I find this mapping more convenient than the default `->`, since I can reach it without
|
||||
moving my fingers from the home row and it is easy to remember `tab` and `shift`+`tab`
|
||||
|
@ -242,7 +245,7 @@ helps to identify un-escaped characters in a quoted string.
|
|||
|
||||
### `.zshrc`
|
||||
|
||||
Now that I've explained it in parts, here's my `.zshrc` file in its entirety:
|
||||
Now that I've explained the components, here's my `.zshrc` file in its entirety:
|
||||
|
||||
```
|
||||
# Lines configured by zsh-newuser-install
|
||||
|
@ -379,6 +382,8 @@ server and applying my `.bashrc` without making permanent changes to the remote
|
|||
not apply to connections that use a `RemoteCommand` in the SSH config, which is intentional; I have
|
||||
remotes that run a `tmux` session for remote connections and I wouldn't want to mess with shell
|
||||
configurations when multiple connections will be attaching the same `tmux` session.
|
||||
This also highlights that I still do use `bash` for most of my remote connections, since `bash`
|
||||
is available by default on every Linux distribution I've come across and `zsh` is far less ubiquitous.
|
||||
|
||||
### Conclusion
|
||||
|
||||
|
@ -392,10 +397,10 @@ more pleasant shell experience with extra text highlighting and shortkeys.
|
|||
I have no immediate plans for what to work on next, though I
|
||||
[still have some ideas](https://blog.mcknight.tech/2025/05/21/nvim/#What-to-do-next). I may continue my search for a good
|
||||
visual file manager in the terminal, or try out Pop!_OS for its window tiling features,
|
||||
although I might wait for their [Cosmic DE](https://system76.com/cosmic/) to graduate to
|
||||
although I'll likely wait for their [Cosmic DE](https://system76.com/cosmic/) to graduate to
|
||||
beta and try that.
|
||||
|
||||
I also still have some [IDE exploration to do](https://blog.mcknight.tech/2025/05/18/Code-Server/#Future-Plans).
|
||||
As I spend more time using `nvim`, I am starting to use it more for coding tasks and it may become my primary "IDE".
|
||||
In any case, I am actively messing with my `nvim` configuration, so I probably have enough thoughts for another post
|
||||
In any case, I am actively adding to my `nvim` configuration, so I probably have enough thoughts for another post
|
||||
about that.
|
Loading…
Reference in a new issue