Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac Terminal Strange Behaviour (no newline when hitting enter, no visible text )

I'm on Mac OS X 10.11.3 My terminal looks like this:

[Fabian@MacBook-Pro] > 
[Fabian@MacBook-Pro] > pyspark
Python 2.7.11 (default, Jan 29 2016, 17:48:19) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
16/03/17 10:08:22 WARN NativeCodeLoader: Unable to load native-hadoop library     for your platform... using builtin-java classes where applicable
Welcome to

      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /__ / .__/\_,_/_/ /_/\_\   version 1.6.1
      /_/

Using Python version 2.7.11 (default, Jan 29 2016 17:48:19)
SparkContext available as sc, HiveContext available as sqlContext.
>>> print 'hello'
>>> hello

>>> quit()
>>> [Fabian@MacBook-Pro] > [Fabian@MacBook-Pro] > [Fabian@MacBook-Pro] > [Fabian@MacBook-Pro] > -bash:     printsf: command not found

in the first line I press enter, and as you see, the prompt starts at another line, then I launch pyspark, do something and quit, then when I return to the prompt I press enter and as you can see, the prompt doesn't appear in a newline! I actually type and nothing is printed to the screen, however the commands are executed as you can see

 -bash:     printsf: command not found

my .bash_profile (located in /Users/Fabian folder) looks like this

# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export PYTHONPATH=$PYTHONPATH:/Users/Fabian/Library/Python

##
# Your previous /Users/Fabian/.bash_profile file was backed up as /Users/Fabian/.bash_profile.macports-saved_2016-02-07_at_11:26:24
##

# MacPorts Installer addition on 2016-02-07_at_11:26:24: 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.

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$PATH:/Users/Fabian/apache-maven-3.3.9/bin
export PS1="[\u@\h] > "
export PATH=$PATH:/Users/Fabian/spark-1.6.1-bin-hadoop2.6/bin

How Can I fix this behavior?? Thanks!

like image 431
latorrefabian Avatar asked Mar 17 '16 15:03

latorrefabian


People also ask

How do you do a line break in Terminal?

The most used newline character If you don't want to use echo repeatedly to create new lines in your shell script, then you can use the \n character. The \n is a newline character for Unix-based systems; it helps to push the commands that come after it onto a new line.

How do I skip to the beginning of a line in terminal?

CTRL-A / HOME : Move to the beginning of a line. CTRL-E / END : Move to the end of a line.

How do you skip a line in Terminal Mac?

You can use ctrl-A to jump to the beginning of the line and ctrl-E to jump to the end. ctrl-XX (hold ctrl and press 'x' twice) will jump to the beginning of the line and then back to the current position the second time you use it.


1 Answers

As noted in comments (and as described by OP), the expected newline after each message was lost. That is because the application changed the terminal I/O modes dealing with carriage-return / line-feed, e.g.,

  • pressing Enter (which is a carriage return) was not translated into a newline (actually a line-feed), and
  • newlines sent from the computer were not translated into carriage return / line-feed.

However, on "any" keyboard, you can type a newline by pressing controlJ. The usual fixes apply pressing controlJ first to get a prompt, and completing the command with pressing controlJ):

  • stty sane (resets the terminal driver)
  • reset (resets the terminal driver as well as asking the terminal to reset itself).
like image 125
Thomas Dickey Avatar answered Nov 15 '22 20:11

Thomas Dickey