At some point, I've noticed strange behavior of Terminal app - now on opening new window i get this as normal:

Last login: Tue Nov 27 11:54:21 on ttys001

but can't see the "~" sign afterwards and window title shows "Terminal - sed - 80x24" which means that sed is running. After hitting two times "enter" key, everything goes normal, but now after every new command i enter, i have to hit twice "enter" after it. This drives me insane! Have no idea what happened. Maybe there is some startup-configuration script for terminal/bash? I've checked .bash_profile it looks fine as it used to be.

Here is my .bash_profile file:

export DOCUMENTS=~/Documents
alias twrangler="open -a TextWrangler"
alias countloc="find -f . '(' -name '*.m' -or -name '*.mm' ')' -print | xargs wc -l"

# Terminal colours (after installing GNU coreutils)
# NM="\[\033[0;38m\]" #means no background and white lines
# HI="\[\033[0;37m\]" #change this for letter colors
# HII="\[\033[0;31m\]" #change this for letter colors
# SI="\[\033[0;33m\]" #this is for the current directory
# IN="\[\033[0m\]"
# export PS1="$NM[$SI\w$NM] $IN"

export HISTCONTROL=ignoredups # Ignores dupes in the history
shopt -s checkwinsize # After each command, checks the windows size and changes lines and columns

# bash completion settings (actually, these are readline settings)
bind "set completion-ignore-case on" # note: bind is used instead of setting these in .inputrc. This ignores case in bash completion
bind "set bell-style none" # No bell, because it's damn annoying
bind "set show-all-if-ambiguous On" # this allows you to automatically show completion without double tab-ing

# Turn on advanced bash completion if the file exists (get it here: http://www.caliban.org/bash/index.shtml#completion)
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion

# Useful aliases
alias ls='ls $LS_OPTIONS -hF'
alias ll='ls $LS_OPTIONS -lhF'
alias l='ls $LS_OPTIONS -lAhF'

alias g='grep -i' #case insensitive grep
alias f='find . -iname'
alias ducks='du -cks * | sort -rn|head -11' # Lists the size of all the folders and files
alias top='top -o cpu'
alias systail='tail -f /var/log/system.log'

alias cd..="cd .."
alias c="clear"
alias e="exit"
alias ssh="ssh -X"
alias ..="cd .."
#alias mysqlstart='sudo /opt/local/bin/mysqld_safe5 &'
#alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown'
#alias remount='sudo ~/scripts/remount.rb'
#alias ffman='/Applications/Firefox.app/Contents/MacOS/firefox -ProfileManager'
#alias ffdev='/Applications/Firefox.app/Contents/MacOS/firefox -P rainbow' #' -chrome chrome://chromebug/content/chromebug.xul -firefox'
#alias fft1='/Applications/Firefox.app/Contents/MacOS/firefox -P test1'
#alias ffxr='/Applications/Minefield.app/Contents/MacOS/firefox -P xrefresh-dev' #' -chrome chrome://chromebug/content/chromebug.xul -firefox'
#alias ffxr2='/Applications/Minefield.app/Contents/MacOS/firefox -P xr2' #' -chrome chrome://chromebug/content/chromebug.xul -firefox'
#alias ff13='/Applications/Minefield.app/Contents/MacOS/firefox -P fb13' #' -chrome chrome://chromebug/content/chromebug.xul -firefox'
#alias ffhed='/Applications/Firefox.app/Contents/MacOS/firefox -P hed' #' -chrome chrome://chromebug/content/chromebug.xul -firefox'
#alias ffgae='/Applications/Minefield.app/Contents/MacOS/firefox -P gae' #' -chrome chrome://chromebug/content/chromebug.xul -firefox'
#alias ffgae2='/Applications/Firefox.app/Contents/MacOS/firefox -P gae' #' -chrome chrome://chromebug/content/chromebug.xul -firefox'
#alias runsvn='/usr/bin/sudo -u www /opt/local/bin/svnserve -d -r /var/svn'

#alias spotbuild='sudo mdutil -E /'

if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion


git_dirty_flag() {
git status 2> /dev/null | grep -c : | awk '{if ($1 > 0) print "‚ö°"}'

parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'

prompt_func() {
if test $previous_return_value -eq 0
PS1="${prompt}${COLOR_NONEP}${COLOR_NONE} "
PS1="${prompt}${COLOR_RED}${COLOR_NONE} "

# MacPorts Installer addition on 2011-11-02_at_22:46:11: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
  • Can you add the contents of your startup scripts? Are there any other in your home dir?
    – Gerry
    Nov 27, 2012 at 12:04
  • well, just .bash_profile that i used for ages. it sets up paths, some environmental variables and aliases. its quite big to post here. do you think it could be the issue?
    – peetonn
    Nov 27, 2012 at 15:19
  • ok, maybe you're right. i removed .bash_profile at all and everything works now. hm, the rest is to figure out what caused that behaviour
    – peetonn
    Nov 27, 2012 at 16:08

2 Answers 2


ok, I've found the problem. it was tricky and several different results led to it. but it always wise to figure out our mistakes, so here was mine:

  1. i used .bash_profile file with some settings for convenient use (like aliases, coloring, etc.). i just copied that file from my friend and never looked at it thoroughly, however should done this. there are some bash functions which adds to the variable PROMPT_COMMAND the name of current git branch, so it is convenient when you make cd in this folder, the branch is shown automatically in green color near ~ sign, like this: "~master". you can find this in .bash_profile as prompt_func and parse_git_branch functions. they are using git command

  2. this profile file always worked well. but at some point (today) it stopped. so i just pulled my bash history and after some thorough exploration and thinking have found the problem. here is the excerpt of output from history:

437 curl -s -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
438 chmod u+x git-credential-osxkeychain
439 sudo mv git-credential-osxkeychain `which git`

strange command

sudo mv git-credential-osxkeychain `which git`

was intended to move file git-credential-osxkeychain to the directory, where git resides (which git), for my system it is /usr/bin/git. but what actually was made is that this file was moved to the directory /usr/bin with the name git and the directory with the git itself was just overwritten by that file, e.d. gone!! so now, coming back to the scripts functions in .bash_profile which is using git, everything looks simple and obvious - there is no git, but the file named git (which is executable btw - utility for setting up git credentials) and functions use this utility thinking that it is git itself.

therefore now, solution for me is to restore git installation and rename git file back to git-credential-osxkeychain

resume - never write bash code in one-line unless you clearly understand what will bring each statement of it to the results

thanks for all who took part in this.

  • which returns the full part and not just the directory component I'm afraid.
    – Gerry
    Nov 28, 2012 at 2:56
  • that's true, didn't realize that before
    – peetonn
    Nov 28, 2012 at 9:25

The only other scripts you are sourcing in your .bash_profile are




I would check if they were recently updated and if they are damaged. In any case I would avoid calling both (which could also be the problem). If you use bash-completion from MacPorts just use the second.

  • i've checked it - the if statement not executed, because there is no such file in that directory. anyway, thanks for contribution! i've figured out the problem and posted it as an answer
    – peetonn
    Nov 27, 2012 at 16:45

You must log in to answer this question.

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