Bash/Cygwin - aliases not behaving like command

1

I'm trying to get Cygwin setup the tools I use in Windows and am having some troubles. From this post, I found I could specify Notepad++ as my editor using

alias notepad="/cygdrive/c/Program\ Files\ \(x86\)/Notepad++/notepad++.exe"

And this works when I run it through the command line

notepad $( cygpath -pw ~/.bashrc ) &

opens my .bashrc file, however when I try and make this an alias

alias settings="notepad $( cygpath -pw ~/.bashrc ) &"

and type settings I get the get the error

C:\Program Files (x86)\Notepad++\cygwin64homeuser.bashrc doesn't exist. Create it?

I tried defining a variable and had even more issues. What am I doing wrong?

user1543042

Posted 2018-08-13T02:50:57.217

Reputation: 209

Answers

2

You are using double quotes in the alias command, so whatever is in the double quotes is executed at the time you are setting the alias. You have to use single quotes around the alias definition, so that variables are resolved when the alias is used. For instance, try these two:

alias wtf1='echo $(pwd)'
alias wtf2="echo $(pwd)"

You will see that wtf1 properly reports the current directory, while wtf2 seems stuck on the directory you were in when you set up the alias.

xenoid

Posted 2018-08-13T02:50:57.217

Reputation: 7 552