anr983mfg_d-3
anr983mfg_d-3

Reputation: 47

zsh alias dropping first character at execution

Okay, so my alias is alias pinecalcmanj="scp ~/.local/share/evolution/calendar/system/calendar.ics $pinemanjaro:~/.local/share/evolution/calendar/system/calendar_computer.ics". Running the alias in a command line, I see cp: cannot create regular file ':~/.local/share/evolution/calendar/system/calendar_computer.ics': No such file or directory. If I copy and paste the alias contents into the command line, it runs fine. It seems that the first character in the alias is dropped in the execution.

Here's the interesting rub, though. I added a white space before the 's' and executed the alias, giving the new alias, alias pinecalcmanj=" scp ~/.local/share/evolution/calendar/system/calendar.ics $pinemanjaro:~/.local/share/evolution/calendar/system/calendar_computer.ics". Hey presto, it worked. Great. I saved the alias with the space behind it.

Well, the next time I went to use the alias it didn't work, seeing the same issue, that the 's' wasn't recognised. I removed the white space, saved the zshrc, and ran the alias and it worked. So, it seems that every time I want to use the alias, I need to open the zshrc and either remove a white space or add one in order for it to work. I am very confused here. Any ideas?

Upvotes: 0

Views: 82

Answers (1)

anton.uspishnyi
anton.uspishnyi

Reputation: 352

I think it'll work if you replace double quotes by single quotes, like this:

alias pinecalcmanj='scp ~/.local/share/evolution/calendar/system/calendar.ics $pinemanjaro:~/.local/share/evolution/calendar/system/calendar_computer.ics'

The reason is single quotes won't interpolate anything, but double quotes will. Here is what the Bash manual says:

Upvotes: 2

Related Questions