2

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 ?

0

1 Answer 1

3

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 :(

5
  • @CedricRBR's single quotes should be double quotes, as Mark indicates, but they should not be 'curly' quotes, either.
    – IconDaemon
    Commented Jan 6, 2015 at 12:29
  • 1
    @IconDaemon single quotes ' work as well here
    – mmmmmm
    Commented Jan 6, 2015 at 12:44
  • Agreed, but the examples in the original post are curly, and may be the cause of the problem if present in the .bashrc file, which expects plain text.
    – IconDaemon
    Commented Jan 6, 2015 at 12:46
  • ', " are valid in these alias definitions. ´ is invalid, in the sense it is not a metacharacter but a basic one. bash will read ´defaults as a word, the name of a potential command and this "command" is not found. Which it tells to tell the truth :).
    – dan
    Commented Jan 6, 2015 at 13:50
  • reference: gnu.org/software/bash/manual/bashref.html#index-alias Commented Jan 6, 2015 at 14:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .