I have several ways of defining aliases mixed together and I want to make them all the same. But I don’t even know why I’ve written them in different ways and now I don’t know which to choose. I think ${ZDOTDIR:-$HOME}/.zshrc
is a bad idea. I should just define somewhere and call it here, or I would have to change it in many places if I wanted to change the file location or name. But what about the rest, I have this in one place
'${=EDITOR} "$MYVIMRC"'
and this in another "$EDITOR $TMUXRC"
, which are the same in my opinion.
# Quick access to the .zshrc file
alias ez='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc'
alias zshrc='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc'
alias ev='${=EDITOR} "$MYVIMRC"' # edit vimrc
alias vimrc='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc'
alias et="$EDITOR $TMUXRC" # edit tmux.conf
alias tmuxrc="$EDITOR $TMUXRC"
A place to learn programming.
Share free resources here.
Ask questions on heapoverflow.ml
Python docs (tutorial)
Javascript docs (node)
Hard challenges (Project Euler)
I think you are better off setting something like
$MYZSHRC
and using that.What does
${=EDITOR}
do? Asking about the equals sign.EDIT:
${=spec} Perform word splitting using the rules for SH_WORD_SPLIT during the evaluation of spec, but regardless of whether the parameter appears in double quotes; if the `=' is doubled, turn it off. This forces parameter expansions to be split into separate words before substitution, using IFS as a delimiter. This is done by default in most other shells. Note that splitting is applied to word in the assignment forms of spec before the assignment to name is performed. This affects the result of array assignments with the A flag.
You should just use
$EDITOR
there instead. No need to split words.I’ve leaved it at this:
# Quick access to the configuration files alias ez='${EDITOR} ${ZSHRC}' alias eenv='${EDITOR} ${ZSHENV}' alias ev='${EDITOR} ${MYVIMRC}' alias et='${EDITOR} ${TMUXRC}'
I thought that if you use single quotes then dollar variables are not expanded
Actually, you were right, I hadn’t reloaded the configuration, and now that I have, the variables are not expanding in the single quotes.
It seems to be expanding correctly for me:
which et et: aliased to VIM= VIMRUNTIME= nvim /home/ajr/cloud/config/dotfiles/tmux/tmux.conf