0

I've just gotten a 16" 2019 Macbook Pro, and similar to my 13" 2015 MBP, bash seems to hang and generally be a lot laggier than it is on Linux distros. For example, when hitting return to make a new blank line, for a fraction of a second the line remains blank until the next prompt appears.

A worse example is running a command with an empty pipe at the end. e.g.:

echo "hello" |

which results in the prompt waiting for input. When cancelling this with CTRL+C, the mac takes over 2 full seconds to cancel and prep for the next line.

Is this a known issue or something? I've gotten the top-range Intel MBP from 2019 and something as simple as running basic Unix commands on a command prompt feels slower than a regular linux distro.

EDIT: I've attached my .bash_profile as this seemed to speed things up at least a little, although I don't think it's the root cause of the problem as I've run this on other Linux distros with none of these laggy problems.

# .bashrc

if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi

export PATH=$HOME/.sdkman/candidates/gradle/current/bin:$HOME/.local/bin:$HOME/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/local/go/bin:/bin:/sbin:/$HOME/go/bin

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

function parse_git_branch() {
    BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
    if [ ! "${BRANCH}" == "" ]
    then
        STAT=`parse_git_dirty`
        echo "[${BRANCH}${STAT}]"
    else
        echo ""
    fi
}

function parse_git_branch() {
    BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
    if [ ! "${BRANCH}" == "" ]
    then
        STAT=`parse_git_dirty`
        echo "[${BRANCH}${STAT}]"
    else
        echo ""
    fi
}


function parse_git_dirty {
    status=`git status 2>&1 | tee`
    dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
    untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
    ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
    newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
    renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
    deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
    bits=''
    if [ "${renamed}" == "0" ]; then
        bits=">${bits}"
    fi
    if [ "${ahead}" == "0" ]; then
        bits="*${bits}"
    fi
    if [ "${newfile}" == "0" ]; then
        bits="+${bits}"
    fi
    if [ "${untracked}" == "0" ]; then
        bits="?${bits}"
    fi
    if [ "${deleted}" == "0" ]; then
        bits="x${bits}"
    fi
    if [ "${dirty}" == "0" ]; then
        bits="!${bits}"
    fi
    if [ ! "${bits}" == "" ]; then
        echo " ${bits}"
    else
        echo ""
    fi
}

export PS1="\[$(tput bold)\]\u@\h:\[$(tput sgr0)\]\[\033[38;5;39m\]\w\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;11m\]\[$(tput bold)\]\`parse_git_branch\`\[\e[m\] \[$(tput sgr0)\]"
export JQ_COLORS="1;30:0;39:0;39:0;39:0;32:1;39:1;39"

alias revertterm='setterm -term linux -back default'
term_title() { echo -ne "\033]2;$*\007"; }
reset_term() { term_title "Terminal"; revertterm; }

alias_ssh() { term_title "$*"; "ssh" -t $*; reset_term; }
alias ssh=alias_ssh

ssh_live() { setterm -term linux -back red; ssh $*; }
ssh_stg() { setterm -term linux -back blue; ssh $*; }


export GREP_COLORS='fn=1;94'
export HISTSIZE=10000
HISTTIMEFORMAT="%d/%m/%y %T  "
export HISTIGNORE="history*:hg*:rst:rm -rf*:ll*:ls:man*:"

export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
export PATH=$PATH:/.sdkman/candidates/java/current/bin
complete -C complete_gwctl gwctl

ulimit -n 200000

[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

if [ -x /usr/bin/dircolors ]; then
   test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
   alias ls='ls --color=auto'
   alias grep='grep --color=auto'
   alias fgrep='fgrep --color=auto'
   alias egrep='egrep --color=auto'
fi
10
  • Which macOS are you running? What does Activity Monitor tell you?
    – lhf
    Sep 20 at 17:42
  • What does bash do if you don't use whatever custom script you have in its startup files? Sep 20 at 18:03
  • 1
    Bash has a selection of startup files as described in the INVOCATION section of its man page. If you invoke bash with bash --noprofile --norc , does this behavior still occur? Sep 20 at 18:18
  • 1
    Please add your .bash_profile to the question. Sep 20 at 19:21
  • 1
    I think it's the sdkman stuff, it adds to $PROMPT_COMMAND and you describe the slowness occurring between prompts. If you put everything back and don't do the sdkman init, I imagine it behaves much better. Sep 20 at 22:45

You must log in to answer this question.

Browse other questions tagged .