I’ve recently started playing around with nixos, working on porting my dots over. Starting with the basics I’ve installed helix editor and started to configure zsh and ohMyZsh etc.
I have helix installed as a systemPackage
My zsh config is in a separate file, under /etc/nixos/zsh/default.nix and for now is a fairly basic setup:
So the issue I’m having is that within zsh, if i issue a hx command, i get: helix: command not found
If i switch back to bash the same command opens helix editor as expected.
Interestingly I’ve set SUDO-EDITOR='hx" and in both bash and zsh and as a result I’m able to edit configs using sudoedit
In zsh, my PATH contains a reference to /run/current-system/sw/bin which i believe is where my helix binary is linked to.
If I run ./run/current-system/sw/bin/hx helix opens just fine
I have configured zsh with parts of my configs from my old dotfiles, whilst i wait a reply I’m going to attempt a clean configuration of zsh, ohMyZsh etc with all defaults to rule out any potentially conflicts i may have inadvertently introduces from my old dots.
Maybe shot in the dark, but is oh-my-zsh trying to be cute with aliases by injecting alias hx=helix while the actual binary is literally hx? Check whence hx in zsh
side note: I’ve never heard of whence seems to do the same thing where?
Additional I’ve just ran a clean install with default zsh configs and helix is working as expected. Digging through my configs I found an alias for hx=helix which was carried over from on of my old macbook configs (iirc the helix binary is called helix on osx and hx everywhere else)
IIRC whence is a builtin in some shells, but AFAIK type <blah> is a more portable/useful way to answer this question across posixy shells (and type -a <blah>, which is also supported in most cases, is even more useful).
Here’s an example with output from each of the stock shells that shipped on a fairly old macOS:
$ bash -c 'type -a whence git'
bash: line 1: type: whence: not found
git is /run/current-system/sw/bin/git
git is /usr/bin/git
$ csh -c 'type -a whence git'
/usr/bin/type: line 4: type: whence: not found
git is /run/current-system/sw/bin/git
git is /usr/bin/git
(note that type wasn't actually supported in csh here; it fell back on a 'type' from PATH)
$ dash -c 'type -a whence git'
-a: not found
whence: not found
git is /run/current-system/sw/bin/git
$ ksh -c 'type -a whence git'
whence is a shell builtin
git is a tracked alias for /run/current-system/sw/bin/git
git is /usr/bin/git
$ sh -c 'type -a whence git'
sh: line 1: type: whence: not found
git is /run/current-system/sw/bin/git
git is /usr/bin/git
$ tcsh -c 'type -a whence git'
/usr/bin/type: line 4: type: whence: not found
git is /run/current-system/sw/bin/git
git is /usr/bin/git
(note that type wasn't actually supported in tcsh here; it fell back on a 'type' from PATH)
$ zsh -c 'type -a whence git'
whence is a shell builtin
git is /run/current-system/sw/bin/git
git is /usr/bin/git
Edit: not sure if there’s a genuinely ubiquitous POSIX form here. IIRC type is POSIX, so I was a little surprised by the fact that it looks like the csh/tcsh shells here indicate it is running through /usr/bin/type. I don’t know much about tcsh and csh, so I’ll resist falling down that rabbit-hole