This question is not a duplicate of Why alias behave different than running bash command directly? because I have tried that solution and it hasn't worked. I replaced all my single quotes with double quotes and vice-versa. The command works neither way.
I am trying to implement an alias, sys
, that will open a file I keep track of changes to my system in, sys.md
, append a date, yank that line, paste the line, replace it with -
's for the markdown h2 format, open a new line, and insert a -
for the markdown bullet format. From vi.stackexchange.com I received some help implementing the command. It works:
nvim +'$pu_|r!date' +'norm yypVr-o ' ~/notes/sys.md
When I replace the single quotes with double quotes the $pu_ is evaluated and I get
zsh: event not found: date
So the single quotes are important. However, when I implement the alias
alias sys="nvim +'$pu_|r!date' +'norm yypVr-o- ' ~/notes/sys.md"
The alias fails. nvim
opens , but the date is appended to the second line and not the bottom. Clearly $pu_ is being evaluated as a variable from BASH. (nvim
's syntax checker even shows it to be evaluated.) Inverting the doubles and singles to yield
alias sys='nvim +"$pu_|r!date" +"norm yypVr-o- " ~/notes/sys.md'
Has the same behavior. Backticks,
alias sys=`nvim +"$pu_|r!date" +"norm yypVr-o- " ~/notes/sys.md`
Freezes bash on source .zshrc
. I don't know how to proceed. Any help would be greatly appreciated.
$
in$pu_
not work? – Rakesh Sharma Aug 25 '18 at 17:36