zsh and GNU stow #14

Merged
d_mcknight merged 3 commits from DOC_ZshGnuStow into main 2025-06-05 18:46:05 -07:00
Showing only changes of commit f85c29c2d2 - Show all commits

View file

@ -1,4 +1,4 @@
______________________________________________________________________ ---
date: 2025-06-04 date: 2025-06-04
title: zsh and GNU stow title: zsh and GNU stow
@ -8,7 +8,7 @@ tags:
- linux - linux
- development - development
______________________________________________________________________ ---
In [my last post exploring `nvim`](https://blog.mcknight.tech/2025/05/21/nvim/), I mentioned some potential next projects on my agenda. In [my last post exploring `nvim`](https://blog.mcknight.tech/2025/05/21/nvim/), I mentioned some potential next projects on my agenda.
Well, I wasted no time continuing down the path of trying to perfect my shell experience. I very quickly updated my Well, I wasted no time continuing down the path of trying to perfect my shell experience. I very quickly updated my
@ -102,13 +102,13 @@ haven't run into any issues thus far and `zsh` is good enough to be the default
operating systems, including macOS and TrueNAS. operating systems, including macOS and TrueNAS.
There are a couple reasons I decided to try `zsh`, the first being tab completion which 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. 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. The other reasons I wanted to experiment with `zsh` are a bit more complex.
### RC Files ### RC Files
[Run Commands files](https://en.wikipedia.org/wiki/RUNCOM) are basically files that [Run Commands files](https://en.wikipedia.org/wiki/RUNCOM) are basically files that
are executed when a program starts. I 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. which is executed whenever I open a new `bash` shell.
I wanted to experiment with `zsh` configuration because it feels a little more modern I wanted to experiment with `zsh` configuration because it feels a little more modern
@ -189,7 +189,7 @@ I use different aliases for different shells (i.e. `sudosu` is shell-specific).
### `zsh` Plugins ### `zsh` Plugins
Another interesting feature of `zsh` is that it supports 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 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), 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),
@ -197,44 +197,53 @@ I settled on [Zinit](https://github.com/zdharma-continuum/zinit) as a lightweigh
apparently maintained option. apparently maintained option.
#### OMZ extract #### OMZ extract
This convenience command lets me extract files without having to remember the syntax for
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>`
#### OMZ colored-man-pages #### OMZ colored-man-pages
This adds some color to man pages which I think makes it a little easier to skim to find 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 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. here when trying to skim through what can be pretty dense documentation.
#### OMZ encode64 #### OMZ encode64
It isn't every day that I need to get a b64-encoded representation of a string, but its It isn't every day that I need to get a b64-encoded representation of a string, but its
handy to be able to do so quickly and easily. handy to be able to do so quickly and easily.
#### OMZ pip #### OMZ pip
I like having tab completion for pip. I haven't used it too much yet, but I already see I like having tab completion for pip. I haven't used it too much yet, but I already see
how this will save me from trying to `pip isntall` when I really mean `pip install`. I how this will save me from trying to `pip isntall` when I really mean `pip install`. I
do this more than I'd like to admit. Other than that, its nice to have reminders for the do this more than I'd like to admit. Other than that, its nice to have reminders for the
less commonly used flags. less commonly used flags.
#### OMZ sudo #### OMZ sudo
The Oh My Zsh sudo plugin adds a convenience keybind (`esc`+`esc`) to prepend `sudo` to 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 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 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.
#### zsh-autosuggestions #### zsh-autosuggestions
This plugin works much like suggestions in an IDE, providing a suggested command completion This plugin works 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`). 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 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` moving my fingers from the home row and it is easy to remember `tab` and `shift`+`tab`
are both a kind of completion. are both a kind of completion.
#### zsh-syntax-highlighting #### zsh-syntax-highlighting
This plugin highlights syntax as you type in a command. This clearly identifies unresolved This plugin highlights syntax as you type in a command. This clearly identifies unresolved
commands or files to help catch errors before trying to run an incomplete command. It also commands or files to help catch errors before trying to run an incomplete command. It also
helps to identify un-escaped characters in a quoted string. helps to identify un-escaped characters in a quoted string.
### `.zshrc` ### `.zshrc`
Now that I've explained it in parts, here's my `.zshrc` file in its entirety: Now that I've explained it in parts, here's my `.zshrc` file in its entirety:
``` ```
# Lines configured by zsh-newuser-install # Lines configured by zsh-newuser-install
HISTFILE=~/.histfile HISTFILE=~/.histfile
@ -360,25 +369,27 @@ bindkey '^[[Z' autosuggest-accept
``` ```
#### Some notes on `autossh` #### Some notes on `autossh`
I have only been using `autossh` for a couple hours at this point, based on internet recommendations I have only been using `autossh` for a couple hours at this point, based on internet recommendations
that it will do better at resuming with `tmux` (via `tmux-resurrect`). Based on initial testing, it that it will do better at resuming with `tmux` (via `tmux-resurrect`). Based on initial testing, it
appears to be working but I don't yet know if it is markedly better than plain `ssh`. appears to be working but I don't yet know if it is markedly better than plain `ssh`.
Not necessarily related to `autossh`, the `assh` function I included allows for connecting to a Not necessarily related to `autossh`, the `assh` function I included allows for connecting to a
server and applying my `.bashrc` without making permanent changes to the remote server. This does server and applying my `.bashrc` without making permanent changes to the remote server. This does
not apply to connections that use a `RemoteCommand` in the SSH config, which is intentional; I have 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 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. configurations when multiple connections will be attaching the same `tmux` session.
### Conclusion ### Conclusion
I don't think my shell configuration will ever be "done", but I've reached a point where I'm I don't think my shell configuration will ever be "done", but I've reached a point where I'm
satisfied for now. GNU `stow` has simplified my dotfile management and made it easier to satisfied for now. GNU `stow` has simplified my dotfile management and made it easier to
manage more configurations as I add tools to my repertoire. I now have `zsh` looking like manage more configurations as I add tools to my repertoire. I now have `zsh` looking like
my `bash` shell and all of my aliases and `PATH` management better organized to minimize my `bash` shell and all of my aliases and `PATH` management better organized to minimize
redundant code in shell-specific config files. I've enabled a few zsh plugins that create a redundant code in shell-specific config files. I've enabled a few zsh plugins that create a
more pleasant shell experience with extra text highlighting and shortkeys. more pleasant shell experience with extra text highlighting and shortkeys.
I have no immediate plans for what to work on next, though I 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 [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, 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 might wait for their [Cosmic DE](https://system76.com/cosmic/) to graduate to
@ -388,4 +399,3 @@ I also still have some [IDE exploration to do](https://blog.mcknight.tech/2025/0
As I spend more time using `nvim`, I am starting to use it more for coding tasks and it may become my primary "IDE". 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 messing with my `nvim` configuration, so I probably have enough thoughts for another post
about that. about that.