Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I keep getting `bash: local: command not found`

Tags:

bash

Keep getting this error:

bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   local: command not found
bash:   export: command not found
bash:   export: command not found
bash: ~/.bash_profile: No such file or directory

Here is my bash_profile:

When I comment out the prompt function, the error goes away except the last one!

alias ngrok=/Users/mmahalwy/Desktop/Code/ngrok

export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced

alias ls='ls -GFh'

function prompt {
  local BLACK="\[\033[0;30m\]"
  local BLACKBOLD="\[\033[1;30m\]"
  local RED="\[\033[0;31m\]"
  local REDBOLD="\[\033[1;31m\]"
  local GREEN="\[\033[0;32m\]"
  local GREENBOLD="\[\033[1;32m\]"
  local YELLOW="\[\033[0;33m\]"
  local YELLOWBOLD="\[\033[1;33m\]"
  local BLUE="\[\033[0;34m\]"
  local BLUEBOLD="\[\033[1;34m\]"
  local PURPLE="\[\033[0;35m\]"
  local PURPLEBOLD="\[\033[1;35m\]"
  local CYAN="\[\033[0;36m\]"
  local CYANBOLD="\[\033[1;36m\]"
  local WHITE="\[\033[0;37m\]"
  local WHITEBOLD="\[\033[1;37m\]"
  local RESETCOLOR="\[\e[00m\]"

  export PS1="\n$RED\u $PURPLE@ $GREEN\w $BLUE[\#] → $RESETCOLOR"
  export PS2="| → $RESETCOLOR"
}

# prompt

export PATH=/usr/local/bin:$PATH

source ~/.git-completion.bash
like image 573
Mohamed El Mahallawy Avatar asked Jun 26 '26 19:06

Mohamed El Mahallawy


1 Answers

If local were genuinely not available (for instance, disabled with enable -n local), you would be seeing:

bash: local: command not found

Instead of:

bash:   local: command not found

Those extra spaces are a clue. Look closely at your file (with a hex editor, if you have to), and figure out what those bytes that aren't either spaces or tabs actually are... and change them to genuine ASCII space characters.

There are several non-breaking space variants found in Unicode; I'm guessing that they somehow got into your script. Copy-and-pasting code from the web can be dangerous. :)

like image 108
Charles Duffy Avatar answered Jun 28 '26 09:06

Charles Duffy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!