You are Here:
Download Linux Lite 5.6 Final today - See Release Announcements



X Close Ad
X Close Ad
How do I get long command lines to wrap to the next line?

Author (Read 3745 times)

0 Members and 1 Guest are viewing this topic.

How do I get long command lines to wrap to the next line?
« on: August 30, 2015, 04:13:56 AM »
 

jacatone

  • New to Forums
  • *
  • 27
    Posts
  • Reputation: 2
  • Linux Lite Member

  • CPU: P4

  • MEMORY: 1Gb

  • VIDEO CARD: Radeon 9550
I'm using color in my bash shell but can't get the text to drop to the next line below. Could someone tell me what's wrong here?

export PS1="\[\e[1;31m[\[email protected]\h \W]\$ \e[m "
 


Re: How do I get long command lines to wrap to the next line?
« Reply #1 on: August 30, 2015, 05:42:14 PM »
 

misko_2083

  • Gold Level Poster
  • *******
  • 687
    Posts
  • Reputation: 191
  • Linux Lite Member

  • CPU: Dual core Pentium E5700 3GHz

  • MEMORY: 3Gb

  • VIDEO CARD: GeForce GT 430
I'm using color in my bash shell but can't get the text to drop to the next line below. Could someone tell me what's wrong here?

export PS1="\[\e[1;31m[\[email protected]\h \W]\$ \e[m "
If you want to move the prompt sse the \n switch at the end
Code: [Select]
export PS1="\e[1;31m[\[email protected]\h \W]\$ \e[m \n"
 

Re: How do I get long command lines to wrap to the next line?
« Reply #2 on: August 30, 2015, 08:43:09 PM »
 

jacatone

  • New to Forums
  • *
  • 27
    Posts
  • Reputation: 2
  • Linux Lite Member

  • CPU: P4

  • MEMORY: 1Gb

  • VIDEO CARD: Radeon 9550
Actually, I meant after the $ sign then drop down below to the next line like it would if I didn't add any color.

[email protected]:~$ 64dfg646df4g654fg654d6fg64fd64g6fd4g64fd64g6df4g6fd
5g64fd64g665df4g646sd465464ds646d5f4
 

Re: How do I get long command lines to wrap to the next line?
« Reply #3 on: August 31, 2015, 08:45:33 AM »
 

misko_2083

  • Gold Level Poster
  • *******
  • 687
    Posts
  • Reputation: 191
  • Linux Lite Member

  • CPU: Dual core Pentium E5700 3GHz

  • MEMORY: 3Gb

  • VIDEO CARD: GeForce GT 430
Oh, sorry mate. I was too tired last night.  :)
Let's see...
The colors aren't properly escaped.
Variable expansion and the \[ \] escapes around them make them not count as character positions and the cursor position is not wrong.
This is the proper way to do it:
\[\e[1;31m\]foo
or
\[\e[1;31m\]\[$variable\]

If you want to set it up like this
[email protected]:~$ command...
Code: [Select]
export PS1="\[\e[1;31m\]\[\[email protected]\h:\w\$\] \[\e[0m\] "You could also set it in two colors
[email protected]: ~$
Code: [Select]
export PS1="\[\e[1;31m\]\[\[email protected]\h\] \[\e[0;32m\]\[\W\$\] \[\e[0m\] "From your first example I thought you were going to use the [ ] brackets:
[[email protected]~]$
Code: [Select]
export PS1="\[\e[1;31m\][\[email protected]\h\w]\$ \[\e[0m\] "
 

Re: How do I get long command lines to wrap to the next line?
« Reply #4 on: August 31, 2015, 03:43:41 PM »
 

jacatone

  • New to Forums
  • *
  • 27
    Posts
  • Reputation: 2
  • Linux Lite Member

  • CPU: P4

  • MEMORY: 1Gb

  • VIDEO CARD: Radeon 9550
Ah, it's getting there. It now types over anything added to the second drop down line rather than just continuing on.

[email protected] ~$  54df5dddddddddddddddddddddddddddddddddddddddddddddddddddd
222222dddddddddddddd

should be,

[email protected] ~$  54df5dddddddddddddddddddddddddddddddddddddddddddddddddddd
dddddddddddddd222222
 

Re: How do I get long command lines to wrap to the next line?
« Reply #5 on: September 04, 2015, 10:52:23 PM »
 

shengchieh

  • Forum Regular
  • ***
  • 155
    Posts
  • Reputation: 46
  • Linux Lite Member
    • Tux's Links
For references go to

http://shengchieh.50webs.com/tuxslinks.html#Console%20Commands

Look at scripts???

Sheng-Chieh
 


Tags:
 

X Close Ad
X Close Ad

Download Linux Lite 5.6 Final today - See Release Announcements