13
votes
Accepted
A recommended way to use a command-line utility that isn't added to PATH
One obvious solution is to add the directory containing the program to your PATH setting. This is commonly practiced on Windows, but not on Unix. There are several reasons why this isn't a good idea:
...
10
votes
Accepted
Can .zshrc be modified automatically by other programs, installers, etc.?
It certainly is possible: any program you run has the permission to modify your .zshrc. But in practice, of course, most programs won't do it.
Installers and configurations directly related to zsh are ...
9
votes
'exec fish' at the very bottom of my '.zshrc' - is it possible to bypass it?
This solution sounds to me like it introduces more problems than it solves :) You can simply set the default shell that the macOS Terminal uses in its configuration. No need to set the login shell to ...
6
votes
Accepted
'exec fish' at the very bottom of my '.zshrc' - is it possible to bypass it?
But then, what if I nevertheless want to switch from fish to zsh for some specific reason? Is it possible somehow?
You can check a variable:
[ "$SKIP_FISH" != yes ] && exec fish
...
6
votes
Can .zshrc be modified automatically by other programs, installers, etc.?
By default, there is nothing preventing applications from modifying your account config files.
If this is really a big issue, I suggest copying your config files to a directory, checking everything ...
3
votes
A recommended way to use a command-line utility that isn't added to PATH
I've never had a Mac, but I do this with an alias constantly. If .zshrc is the Mac equivalent of .bashrc, then just add:
if [ -f ~/.zsh_aliases ]; then
. ~/.zsh_aliases
fi
Then run: touch ~/....
2
votes
turning list of file paths from one command into command-line arguments for another
Quoting is part of the syntax of the shell language. You only need quotes if you're writing shell code.
The default xargs input format also understands its own form of quoting, one that is different ...
2
votes
turning list of file paths from one command into command-line arguments for another
If you have an array and just want to pass the elements intact to a command, it's enough to use $array in zsh, or "${array[@]}" (with quotes!) in Bash/ksh. The former drops empty elements, ...
2
votes
Accepted
zsh, macOS: Which file should be used to modify the $PATH variable, and how exactly?
TLDR:
I suggest to use ~/.zshenv and to check the other files that your change does not get overwritten.
Citing https://zsh.sourceforge.io/Guide/zshguide02.html,
section 2.2: All the startup files:
...
1
vote
Accepted
zsh, .bash_profile, and aliases
.bash_profile is only used when initialising login shells. If you want its contents to be interpreted, you need to add -l to your bash invocations.
Alias definitions typically go in .bashrc which is ...
1
vote
Can .zshrc be modified automatically by other programs, installers, etc.?
To complete the other answers, I can give you at least one concrete example: the installation of Anaconda will modify your shell config if you use the default setup. In this answer you can see a code ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
zsh × 3086bash × 581
shell × 536
autocomplete × 324
shell-script × 300
oh-my-zsh × 269
macos × 191
terminal × 162
command-history × 156
command-line × 128
wildcards × 128
alias × 118
prompt × 116
linux × 85
tmux × 75
environment-variables × 73
function × 65
keyboard-shortcuts × 63
ssh × 56
path × 56
scripting × 54
zle × 51
colors × 50
quoting × 45
pipe × 44