"Command not found" lines on terminal startup

Whenever I open my terminal, these lines are displayed:

/Users/USERNAME/.zprofile:2: command not found: bin
/Users/USERNAME/.zprofile:4: command not found: bin
/Users/USERNAME/.zprofile:6: command not found: bin
/Users/USERNAME/.zprofile:8: command not found: bin
/Users/USERNAME/.zprofile:10: command not found: bin
/Users/USERNAME/.zprofile:12: command not found: bin

These are the first 12 lines of my /.zprofile:

alias gtkwave=open -a /Applications/gtkwave.app/Contents/MacOS/gtkwave-
bin source /Users/USERNAME/.zprofile
alias gtkwave=open -a /Applications/gtkwave.app/Contents/MacOS/gtkwave-
bin source /Users/USERNAME/.zprofile
alias gtkwave=open -a /Applications/gtkwave.app/Contents/MacOS/gtkwave-
bin source /Users/USERNAME/.zprofile
alias gtkwave=open -a /Applications/gtkwave.app/Contents/MacOS/gtkwave-
bin source /Users/USERNAME/.zprofile
alias gtkwave=open -a /Applications/gtkwave.app/Contents/MacOS/gtkwave-
bin source /Users/USERNAME/.zprofile
alias gtkwave=open -a /Applications/gtkwave.app/Contents/MacOS/gtkwave-
bin source /Users/USERNAME/.zprofile

Judging by the nature of the output, I'm assuming that something is wrong with my /.zprofile file, but I haven't been able to find the correct way to go in and edit it.

Here's the output that I receive when I type the echo $PATH command:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin

Any help would be greatly appreciated!


Solution 1:

There are a couple of things wrong in your ~/.zprofile:

  1. You have hard-wrapped (i.e., inserted newline characters inside) the alias lines, causing bin to start its own separate line. You need to keep everything on one line.
  2. Shell aliases that include whitespace need to be enclosed in quotes.
  3. You have multiple identical lines, which is generally not useful.
  4. The invocation source ~/.zprofile is recursive and was probably intended as a shell command for you to manually enter after editing ~/.zprofile.

I suspect that ~/.zprofile should simply read:

alias gtkwave="open -a /Applications/gtkwave.app/Contents/MacOS/gtkwave-bin"

EDIT:

Here is a straightforward way to replace the contents of ~/.zprofile:

echo 'alias gtkwave="open -a /Applications/gtkwave.app/Contents/MacOS/gtkwave-bin"' > ~/.zprofile

Note that if there are any other directives that you want to keep (you should examine all of the contents first, e.g., cat ~/.zprofile) then you need to edit instead of overwrite it. You can use any text editor you like. E.g.,

open -e ~/.zprofile

or

vi ~/.zprofile