MacOS – Problem persistently defining aliases in terminal

aliasbashmacosscriptterminal

I am trying to persistently define some aliases for my everyday terminal use. I started off with this tutorial: How to persistently define aliases in Terminal, more precisely with Mike's comment.

As he suggested I created a .bashrc file and symlinked .bash_profile and .profile to it.

My two aliases I created in .bashrc are the following:

alias showFiles= ‘defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder’
alias hideFiles= ‘defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder’

Now I have a problem, when i open a new bash window in Terminal, i get this error message:

-bash: alias: ‘defaults: not found
-bash: alias: write: not found
-bash: alias: com.apple.finder: not found
-bash: alias: AppleShowAllFiles: not found
-bash: alias: TRUE: not found
No matching processes belonging to you were found
-bash: alias: ‘defaults: not found
-bash: alias: write: not found
-bash: alias: com.apple.finder: not found
-bash: alias: AppleShowAllFiles: not found
-bash: alias: FALSE: not found
No matching processes belonging to you were found

Could someone please explain why I get this error and/or how to fix it ?

Best Answer

The alias command requires you to have no spaces around the = and also you should use " or ' to enclose the string not the curly quote ‘ you have. That quote often appears in pdfs and books when the editing program tries to make things look nice.

so the command should be

alias showFiles="defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder"
alias hideFiles="defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder"

I can't find a reference for these but they are just things I have learnt :(