which which is which, and css fix

This commit is contained in:
Tyrel Souza 2023-09-26 15:12:11 -04:00
parent 457ba283a9
commit 9c4012ff96
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E
5 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,37 @@
Which which is which?
#####################
:author: tyrel
:category: Tech
:tags: linux, macos, zsh
:status: published
I had a bit of a "Tyrel you know nothing" moment today with some commandline tooling.
I have been an avid user of ZSH for a decade now, but recently I tried to swap to fish shell.
Along the years, I've maintained a lot of different iterations of `dotfiles <https://gitea.tyrel.dev/tyrel/dotfiles>`_, and shell aliases/functions.
I was talking to a friend about updating from ``exa`` to ``eza`` and then noticed I didn't have my aliases loaded, so I was still using ``ls`` directly, as I have ``alias ls="exa -lhFgxUm --git --time-style long-iso --group-directories-first"`` in my ``.shell_aliases`` file.
I did this by showing the following picture:
.. figure:: {static}/images/2023/09/26_which.png
:alt: Screnshot of shell text saying "Which LS" and then the line under it saying "/usr/bin/ls"
Because I expected it to show me which alias was being pointed to by ``ls``.
My friend pointed out that "Which doesn't show aliases, it only points to files" to which I replied along the lines of "What? No way, I've used ``which`` to show me aliases and functions loads of times."
And promptly sent a screenshot of my system NOT showing that for other aliases I have set up. Things then got conversational and be being confused, to the point of me questioning if "Had I ever successfully done that? Maybe my macbook is set up differrently" and went and grabbed that.
Friend then looked at the man page for which, and noticed that there's the ``--read-alias`` and ``--read-functions`` flags on ``which``, and I didn't have those set.
I then swapped over to bash "Maybe it's a bash thing only? I'm using Fish".
Nope, still nothing! Then went to google, and it turns out that ZSH is what has this setup by default.
Thank you `"Althorion" <https://stackoverflow.com/a/14196212>`_ from Stackoverflow for settling my "Yes you've done this before" confusion.
It turns out that ZSH's ``which`` is equivalent to the ZSH shell built-in ``whence -c`` which shows aliases and functions.
After running ``/usr/bin/zsh`` and sourcing my aliases (I don't have a zshrc file anymore, I need to set that back up), I was able to settle my fears and prove to myself that I wasn't making things up. There is a which which shows you which aliases you have set up, which is default for ZSH.
.. figure:: {static}/images/2023/09/26_ls.png
:alt: Screnshot of shell text saying "Which LS" and then the line under it saying "/usr/bin/ls"

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@ -4,3 +4,5 @@ pub:
venv/bin/invoke publish
live:
venv/bin/invoke livereload
new:
venv/bin/invoke new-post

View File

@ -67,6 +67,8 @@ p {
padding: 2px;
font:12px Monaco,Consolas,"Andale Mono","DejaVu Sans Mono",monospace;
white-space: nowrap;
background-color: #b58900;
color: #000;
}
.literal-block, pre {
@ -79,6 +81,8 @@ p {
padding: 0.5rem;
margin: 0.75rem;
font:12px Monaco,Consolas,"Andale Mono","DejaVu Sans Mono",monospace;
background-color: #b58900;
color: #000;
}