": command not found" in terminal startup

Forum rules
Before you post please read this

": command not found" in terminal startup

Postby rockhazard on Fri Dec 16, 2011 3:03 am

Hey, folks. I have a perplexing problem. When I startup my terminal emulator (GNOME Terminal 3.0.1) or a virtual terminal, it immediately prints ": command not found" above my prompt. I'm thinking it's something in my .bashrc file, although I've used this same unchanged file successfully without a hitch for nearly two years across various versions of Ubuntu and Mint. Any idea what gives? Here is my .bashrc:

Code: Select all
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# user-change begun on 07-20-10

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
   # We have color support; assume it's compliant with Ecma-48
   # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
   # a case would tend to support setf rather than setaf.)
   color_prompt=yes
    else
   color_prompt=
    fi
fi

# ANSI color codes (user-change)
RS="\[\033[0m\]"    # reset (required at end of prompt to stop $HC, $UL, and $INV)
HC="\[\033[1m\]"    # hicolor
UL="\[\033[4m\]"    # underline
INV="\[\033[7m\]"   # inverse background and foreground
FBLK="\[\033[30m\]" # foreground black
FRED="\[\033[31m\]" # foreground red
FGRN="\[\033[32m\]" # foreground green
FYEL="\[\033[33m\]" # foreground yellow
FBLE="\[\033[34m\]" # foreground blue
FMAG="\[\033[35m\]" # foreground magenta
FCYN="\[\033[36m\]" # foreground cyan
FWHT="\[\033[37m\]" # foreground white
BBLK="\[\033[40m\]" # background black
BRED="\[\033[41m\]" # background red
BGRN="\[\033[42m\]" # background green
BYEL="\[\033[43m\]" # background yellow
BBLE="\[\033[44m\]" # background blue
BMAG="\[\033[45m\]" # background magenta
BCYN="\[\033[46m\]" # background cyan
BWHT="\[\033[47m\]" # background white
########################################

if [ "$color_prompt" = yes ]; then
    #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' # original
    PS1="$HC[${debian_chroot:+($debian_chroot)}$FWHT\u$FCYN@$FWHT\h:$FCYN\@:$FCYN\w$RS$HC]\\$ $RS" # user-change
    PS2="> $RS" #user-change
else
    #PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' # original
    PS1="[ ${debian_chroot:+($debian_chroot)}\u@\h: \w ]\\$ " # user-change
    PS2="> " #user-change
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

# editor
export EDITOR=nano


I thought about debugging the file as it runs (like you can for a shell script), but I don't know how for .bashrc. Thanks for any assistance...
rockhazard
Level 1
Level 1
 
Posts: 16
Joined: Wed May 04, 2011 1:44 pm

Linux Mint is funded by ads and donations.
 

Re: ": command not found" in terminal startup

Postby awi on Mon Dec 26, 2011 7:07 pm

Try these
Code: Select all
bash -x ~/.bashrc
awi
Level 1
Level 1
 
Posts: 13
Joined: Wed Nov 23, 2011 8:23 pm
Location: Asunción, Paraguay

Re: ": command not found" in terminal startup

Postby riffraff on Fri Dec 30, 2011 4:55 pm

Maybe your PS1-Setting?

Does /etc/debian_chroot exists? (Because this is in your PS1 right after the ":"...)
riffraff
Level 1
Level 1
 
Posts: 8
Joined: Fri Dec 30, 2011 3:52 am

Re: ": command not found" in terminal startup

Postby Habitual on Fri Dec 30, 2011 5:46 pm

restore the original line.
Code: Select all
    #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' # original
    PS1="$HC[${debian_chroot:+($debian_chroot)}$FWHT\u$FCYN@$FWHT\h:$FCYN\@:$FCYN\w$RS$HC]\\$ $RS" # user-change


THEN, You can test your intended changes by just entering
Code: Select all
PS1="$HC[${debian_chroot:+($debian_chroot)}$FWHT\u$FCYN@$FWHT\h:$FCYN\@:$FCYN\w$RS$HC]\\$ $RS"

in a/the terminal window.

a clock in the prompt?
I get this using your PS1 variable:
Code: Select all
[jj@MyKung-Fu:04:19 PM:~]$


in terminal first, once it works without issue, THEN replace the PS1 line in .bashrc as you have previously.

I have C:\jj > as my prompt, I used to have a clock in there also, but I had unexpected results. It was a painful couple of hours getting it to (mostly) work.

https://wiki.archlinux.org/index.php/Color_Bash_Prompt
http://www.faqs.org/docs/Linux-HOWTO/Ba ... HOWTO.html
http://bash.cyberciti.biz/guide/Changing_bash_prompt

Edit:

I see
Code: Select all
PS2="> $RS"

but no further definition of $RS - where did that come from?
What's a landing but a take off in reverse?
My DorkBlog
User avatar
Habitual
Level 7
Level 7
 
Posts: 1999
Joined: Sun Nov 21, 2010 8:31 pm
Location: Slackware


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 2 guests