This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the unix category.
Last Updated: 2025-10-31
I had an alias for clangd set up in .zshrc.
alias clangd="$(brew --prefix llvm)/bin/clangd"
This was required because I didn't want to risk moving the homebrew C binaries into my path.
In my .vimrc I had:
if executable('clangd')
" code to set up LSP
endif
Despite this, the LSP code never executed. This turned out to be because when
you run !<cmd> in vim or /bin/bash -c <cmd> from another shell, you are
launching an instance of bash in non-interactive mode. And in non-interactive
mode aliases are not expanded.
.zshrc will not be booted.
However all shells will boot the .zshenv file)$PS1 (Prompt String 1) is not setFor example, in a script, which you run with zsh filename. Technically you
have two shells here: the interactive one you are using to start up the script,
and the non-interactive one running the commands.
You can explicitly request a login zsh shell with zsh -l (l for login)