3

This problem is quite annoying and I cannot search Google for 'set -x' because the minus sign has another terminology there.

In my MacBookPro, when I use 'set -x' to debug bash commands, I'm getting the following each time I press enter. Any idea how to stop this ugly dump? because of this, for each command I run, I need to scroll back two pages to find the actual command I was running.

++ update_terminal_cwd
++ local url_path=
++ local i ch hexch LC_CTYPE=C LC_ALL=
++ (( i = 0 ))
++ (( i < 24 ))
++ ch=/
++ [[ / =~ [/._~A-Za-z0-9-] ]]
++ url_path+=/
++ (( ++i ))
++ (( i < 24 ))
++ ch=U
++ [[ U =~ [/._~A-Za-z0-9-] ]]
++ url_path+=U
++ (( ++i ))
++ (( i < 24 ))
++ ch=s
++ [[ s =~ [/._~A-Za-z0-9-] ]]
++ url_path+=s
++ (( ++i ))
++ (( i < 24 ))
++ ch=e
++ [[ e =~ [/._~A-Za-z0-9-] ]]
++ url_path+=e
++ (( ++i ))
++ (( i < 24 ))
++ ch=r
++ [[ r =~ [/._~A-Za-z0-9-] ]]
++ url_path+=r
++ (( ++i ))
++ (( i < 24 ))
++ ch=s
++ [[ s =~ [/._~A-Za-z0-9-] ]]
++ url_path+=s
++ (( ++i ))
++ (( i < 24 ))
++ ch=/
++ [[ / =~ [/._~A-Za-z0-9-] ]]
++ url_path+=/
++ (( ++i ))
++ (( i < 24 ))
++ ch=i
++ [[ i =~ [/._~A-Za-z0-9-] ]]
++ url_path+=i
++ (( ++i ))
++ (( i < 24 ))
++ ch=s
++ [[ s =~ [/._~A-Za-z0-9-] ]]
++ url_path+=s
++ (( ++i ))
++ (( i < 24 ))
++ ch=h
++ [[ h =~ [/._~A-Za-z0-9-] ]]
++ url_path+=h
++ (( ++i ))
++ (( i < 24 ))
++ ch=a
++ [[ a =~ [/._~A-Za-z0-9-] ]]
++ url_path+=a
++ (( ++i ))
++ (( i < 24 ))
++ ch=h
++ [[ h =~ [/._~A-Za-z0-9-] ]]
++ url_path+=h
++ (( ++i ))
++ (( i < 24 ))
++ ch=a
++ [[ a =~ [/._~A-Za-z0-9-] ]]
++ url_path+=a
++ (( ++i ))
++ (( i < 24 ))
++ ch=k
++ [[ k =~ [/._~A-Za-z0-9-] ]]
++ url_path+=k
++ (( ++i ))
++ (( i < 24 ))
++ ch=/
++ [[ / =~ [/._~A-Za-z0-9-] ]]
++ url_path+=/
++ (( ++i ))
++ (( i < 24 ))
++ ch=D
++ [[ D =~ [/._~A-Za-z0-9-] ]]
++ url_path+=D
++ (( ++i ))
++ (( i < 24 ))
++ ch=o
++ [[ o =~ [/._~A-Za-z0-9-] ]]
++ url_path+=o
++ (( ++i ))
++ (( i < 24 ))
++ ch=w
++ [[ w =~ [/._~A-Za-z0-9-] ]]
++ url_path+=w
++ (( ++i ))
++ (( i < 24 ))
++ ch=n
++ [[ n =~ [/._~A-Za-z0-9-] ]]
++ url_path+=n
++ (( ++i ))
++ (( i < 24 ))
++ ch=l
++ [[ l =~ [/._~A-Za-z0-9-] ]]
++ url_path+=l
++ (( ++i ))
++ (( i < 24 ))
++ ch=o
++ [[ o =~ [/._~A-Za-z0-9-] ]]
++ url_path+=o
++ (( ++i ))
++ (( i < 24 ))
++ ch=a
++ [[ a =~ [/._~A-Za-z0-9-] ]]
++ url_path+=a
++ (( ++i ))
++ (( i < 24 ))
++ ch=d
++ [[ d =~ [/._~A-Za-z0-9-] ]]
++ url_path+=d
++ (( ++i ))
++ (( i < 24 ))
++ ch=s
++ [[ s =~ [/._~A-Za-z0-9-] ]]
++ url_path+=s
++ (( ++i ))
++ (( i < 24 ))

Thank you!!

4

What you're seeing here is some fancy behind-the-scenes scriptery that Apple added in OS X 10.11 to set the Terminal window title based on the current working directory. Since set -x shows what commands are being executed by bash, it also winds up showing all this normally-behind-the-scenes stuff (in painful detail). It's fairly easy to disable it, though:

unset PROMPT_COMMAND

... and then you can debug in peace, but your window title bar won't update any more. If you're done debugging and want to re-enable title bar updates, just reset the variable:

PROMPT_COMMAND=update_terminal_cwd
1

Add this line to your .bashrc or .bash_profile if you don't want to see the "garbage" anymore.

PROMPT_COMMAND="{ ${PROMPT_COMMAND}; } 2>/dev/null"

caveat: stderr output from ${PROMPT_COMMAND} will be muted.

0

The place to look is the bash manual

This includes

Using ‘+’ rather than ‘-’ causes these options to be turned off.

So try set +x

  • I probably didn't explain myself well. I do want the set -x, but I don't want this ugly stuff - only the commands which I actually run. Of course set +x will disable it. It will also turn off my debugging... – ishahak May 18 '16 at 14:37
  • Can you edit the question to make this clear (My answer is not likely to change much the answer is on the bash documentation page -v) – user151019 May 18 '16 at 14:39
  • I tried better... – ishahak May 18 '16 at 15:25
  • Still not clear - cut down the original example and then show what you want to see. – user151019 May 18 '16 at 15:45

You must log in to answer this question.

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