Tai
Tai

Reputation: 1254

Why is my terminal alias failing

I'm reading this: http://www.maclife.com/article/columns/terminal_101_creating_aliases_commands

I wrote in my bash profile: alias workspace = 'cd Documents/workspace'

however I get the following:

-bash: alias: workspace: not found
-bash: alias: =: not found
-bash: alias: cd Documents/workspace: not found

when I source the file. What's going on?

I searched on SO and found: .bash_profile aliases: command not found but I'm not using double quotes

Upvotes: 0

Views: 85

Answers (1)

codess
codess

Reputation: 366

Please consider removing the spaces around the = sign.

For reference: http://www.gnu.org/software/bash/manual/bashref.html#Bash-Builtins

This is not on mac, but still bash:

$ cat with-spaces.sh
alias workspace = 'cd Documents/workspace'
$ . with-spaces.sh
./with-spaces.sh: line 1: alias: workspace: not found
./with-spaces.sh: line 1: alias: =: not found
./with-spaces.sh: line 1: alias: cd Documents/workspace: not found
$ # checking result...
$ alias workspace
bash: alias: workspace: not found

$ cat without-spaces.sh
alias workspace='cd Documents/workspace'
$ . without-spaces.sh
$ # checking result...
$ alias workspace
alias workspace='cd Documents/workspace'

Upvotes: 2

Related Questions