Good Morning-  I'm trying to use tput outputs in my $PS1 to set the background color to red in the event I'm on a production server:  if [[ `hostname -s` = prod-db ]]; then   export PS1="${TITLEBAR}`tput setab 1`[\u@\h \W \$ORACLE_SID]\$`tput setab 0` " else   export PS1="${TITLEBAR}[\u@\h \W \$ORACLE_SID]\$ " fi  However, I'm finding that when I'm on prod-db, the line wrapping is quite messed up; it seems fixed to a certain number of characters and does that fun thing where modifying a command that goes too long goes up a line without redrawing the screen as though the terminal is entirely messed up.  When the background color is not set, none of those issues occur... I'm happy.  PS1 is being set to [\e]0;\u@\h echo $ORACLE_SID\a]^[[41m[\u@\h \W $ORACLE_SID]$^[[40m with colors and to [\e]0;\u@\h echo $ORACLE_SID\a][\u@\h \W $ORACLE_SID]$ without colors.  The only difference being the escape characters being set to set the colors, I don't see what would be breaking the line wrapping.  I'm running GNU bash 4.1.2.  Why does the introduction of the color escape codes cause line wrapping to break, and what is the proper way to resolve the issue?
120470
The first two chars were repeated while I use Tab to do completion. In the screenshot below, cd is repeated.    I have tried rxvt-unicdoe, xterm, terminator.  All these terminal emulators have this issue.  Zsh version 5.0.2, config file
108441
I have been learning bash, and while doing so I played around with the .bash_profile file to be able to put greeting messages etc. Later I just removed these changes. But after doing that my default configuration of prompt got lost: originally, the prompt was all in bold, and \w part was blue so that when I was in a deeply nested directory the prompt would not seem so entangled. I think that was the default for Ubuntu (correct me if i'm wrong), however like  I said it got lost and my prompt was non-bold and monochromatic resulting in a mess when I'm in long named directories.  So, last night I tried customizing my prompt in the fashion I mentioned above. It worked well after I added the code to .bash_profile  Code was like this:  export PS1="\[$(tput bold)\]\u@\h:\[$(tput sgr 0)\]\e[1;34m\w$ \e[m"   However if I try to run another bash shell in the current one, the prompt becomes unformatted:    Is that normal? Isn't the whole point of exporting a variable to make it accessible from all the child processes forked from that shell? Why it doesn't that apply to this situation?
5278
I managed to do this  echo -n "command" &gt; /dev/tty1  The letters appear, and the cursor moves, but they are "ghosts" – if you hit Enter, nothing happens (they are not in stdin).  Edit:  In the middle of the below screenshot, you see why I see the use of this. (The line with a red caption, right below the line with a yellow caption.) As it is now, you are not really "editing" the note text; you are just asked to write a new text, which will replace the text of the note you are (not really) editing. Thus, I thought it could be remedied by simply pasting the old text into the tty: if the user hits enter, no modification is made. (This program is in Perl/MySQL, but I thought it would be more interesting to ask for a general solution than "how do I do this in Perl".)    Edit 2:  Here is the Perl code, that uses the C code below (works exactly as intended), as well as a new screenshot – hopefully this will clarify things beyond doubt :) Again, look at the middle of the screenshot, where the edit is made to the note text - this time around, the old text is there, for example if you just wanted to fix a typo, you won't have to retype the entire note text.  my $edit_note_text = $edit_note_data[2]; print BOLD, RED, " new text: ", RESET; system("writevt /dev/tty \"$edit_note_text\""); my $new_text = &lt;$in&gt;; $new_text = fix_input($new_text); my $set_text = "UPDATE notes SET note = \"$new_text\" WHERE id = $edit_note_id"; $db-&gt;do($set_text);
1075
My current prompt is colorized and edited as so -  #!/bin/bash  # GIT Prompt help if tput setaf 1 &amp;&gt; /dev/null; then     tput sgr0; # reset colors     bold=$(tput bold);     reset=$(tput sgr0);     txtund=$(tput sgr 0 1);     black=$(tput setaf 0);     blue=$(tput setaf 33);     cyan=$(tput setaf 37);     green=$(tput setaf 64);     orange=$(tput setaf 166);     purple=$(tput setaf 125);     red=$(tput setaf 124);     violet=$(tput setaf 61);     white=$(tput setaf 15);     yellow=$(tput setaf 136); else     bold='';     reset="\e[0m";     black="\e[1;30m";     blue="\e[1;34m";     cyan="\e[1;36m";     green="\e[1;32m";     orange="\e[1;33m";     purple="\e[1;35m";     red="\e[1;31m";     violet="\e[1;35m";     white="\e[1;37m";     yellow="\e[1;33m"; fi; ORIG=$PS1 HOST=$HOSTNAME PS1="\[${txtund}${green}\]${HOST}\[\[${reset}\]"; PS1+="\$(prompt_git \"\[${white}\] on \[${violet}\]\")"; PS1+="\[${reset}\]"; PS1+="\[ at - ${orange}\W\]"; PS1+="\[${reset}\]"; PS1+="\[ - \u \]"; PS1+="\n\$ ";   I know that the line  PS1+="[ - \u ]"; will show me my current user. However, I want that section to be red if it is root. All other users should be the default color of gray. Is there a way to change the color in that section based off of current user or should I just declare a variable and use an IF statement to insert that section or a modified section with red as a color?  My expected output is gray named user for all normal users. Root should be red. This is BASH.
789
Something I have noticed in Ubuntu for a long time that has been frustrating to me is when I am typing a command at the command line that gets longer (wider) than the terminal width, instead of wrapping to a new line, it goes back to column 1 on the same line and starts over-writing the beginning of my command line. (It doesn't actually overwrite the actual command, but visually, it is overwriting the text that was displayed).  It's hard to explain without seeing it, but let's say my terminal was 20 characters wide (Mine is more like 120 characters - but for the sake of an example), and I want to echo the English alphabet.  What I type is this:  echo abcdefghijklmnopqrstuvwxyz   But what my terminal looks like before I hit the  key is:  pqrstuvwxyzghijklmno   When I hit enter, it echos  abcdefghijklmnopqrstuvwxyz   so I know the command was received properly.  It just wrapped my typing after the "o" and started over on the same line.    What I would expect to happen, if I typed this command in on a terminal that was only 20 characters wide would be this:  echo abcdefghijklmno pqrstuvwxyz   Background: I am using bash as my shell, and I have this line in my ~/.bashrc:  set -o vi   to be able to navigate the command line with VI commands.  I am currently using Ubuntu 10.10 server, and connecting to the server with Putty.  In any other environment I have worked in, if I type a long command line, it will add a new line underneath the line I am working on when my command gets longer than the terminal width and when I keep typing I can see my command on 2 different lines.  But for as long as I can remember using Ubuntu, my long commands only occupy 1 line.  This also happens when I am going back to previous commands in the history (I hit Esc, then 'K' to go back to previous commands) - when I get to a previous command that was longer than the terminal width, the command line gets mangled and I cannot tell where I am at in the command.  The only work-around I have found to see the entire long command is to hit "Esc-V", which opens up the current command in a VI editor.  I don't think I have anything odd in my .bashrc file.  I commented out the "set -o vi" line, and I still had the problem.  I downloaded a fresh copy of Putty and didn't make any changes to the configuration - I just typed in my host name to connect, and I still have the problem, so I don't think it's anything with Putty (unless I need to make some config changes)  Has anyone else had this problem, and can anyone think of how to fix it?  Edit  It was my .bashrc file.  I've copied the same profile from machine to machine, and I used special characters in my $PS1 that are somehow throwing it off.  I'm now sticking with the standard bash variables for my $PS1.  Thanks to @ændrük for the tip on the .bashrc!  ...End Edit...
73884
I've tried to change my prompt by editing .bashrc:  export PS1="\e[0;32m[\u@\h \W]\$ \e[m"   This seems to work, but ctrl-r to access reverse history ends up with my typing not appearing in the same place as it will be interpreted (like ). It is fine when using the up or down arrows to select previous commands though.  I've had a look at that question, but can't seem to work out where to apply the escape characters in my prompt. I've tried a few combinations but then I break normal text typing functionality or simple back/forwards through history.  If you could include an explanation of which instances of characters need escaping and why, that would help me (and hopefully others) learn.
6109
I spend most of my time working in Unix environments and using terminal emulators. I try to use color on the command line, because color makes the output more useful and intuitive.  What options exist to add color to my terminal environment? What tricks do you use? What pitfalls have you encountered?  Unfortunately, support for color varies depending on terminal type, OS, TERM setting, utility, buggy implementations, etc.  Here are some tips from my setup, after a lot of experimentation:   I tend to set TERM=xterm-color, which is supported on most hosts (but not all). I work on a number of different hosts, different OS versions, etc. I use everything from macOS X, Ubuntu Linux, RHEL/CentOS/Scientific Linux and FreeBSD. I'm trying to keep things simple and generic, if possible. I do a bunch of work using GNU screen, which adds another layer of fun. Many OSs set things like dircolors and by default, and I don't want to modify this on a hundred different hosts. So I try to stick with the defaults. Instead, I tweak my terminal's color configuration. Use color for some  (ls, grep, less, vim) and the . These commands seem to use the standard "". For example:  alias less='less --RAW-CONTROL-CHARS' export LS_OPTS='--color=auto' alias ls='ls ${LS_OPTS}'    I'll post my .bashrc and answer my own question Jeopardy Style.
120787
I know that a similar question has been asked in:        although I didn't really understand the answer and couldn't really make it work.  However, I have tried something different. I decided to read the manual page for ls and it mentions different environment variables that can be set when dealing with the ls command. If one goes to the -G option it says to look at the CLICOLOR environment variables. I did and that one links you to documentation for the LSCOLORS environment variable. I went to it and it mentions:     "The value of this variable describes what color to use for which attribute when colors are enabled with CLICOLOR. This string is a concatenation of pairs of the format fb, where f is the foreground color and b is the background color. "   It also mentions that the default value of LSCOLORS is "exfxcxdxbxegedabagacad" and that each part specifies the color of some specific thing in the ls command. For example, the first pair ex in example specifies the color of directories. the second fx the color of symbolic links etc... e means blue and x means default "foreground".  1) First what does this mean: "when colors are enabled with CLICOLOR"?  2) What does "foreground" mean?  What must environment variables be for the ls command to color the output however I desire?    I also tried:  ls --color   But it threw me the following error:  ls: illegal option -- - usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]   The same error happened when I did ls --color=auto: it alone also throws an error. I have no idea why, and am not sure if it was due to iTerm2 or OS X or why that happened. It seems it works on other systems...
111657
First of all it doesn't load my PS1. It just prompts me with a $ The arrow keys instead of doing what they're supposed to do, the just echo things like: $ ^[[A   And that makes it very unusable. A couple of things to consider here:   This only happens when I login through ssh, it doesn't happen when I login directly to the server. One of the users works pretty fine even with ssh; and that's the user that was setup during the installation of the OS (ubuntu server 14.04). When I su - otherUser from within that user that works fine, everything works fine.   Here's the .bashrc in case you want to take a look at it (It is the same on all users including the one that works correctly):   function parse_git_branch () {   git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' }  RED="\[\033[0;31m\]" YELLOW="\[\033[0;33m\]" GREEN="\[\033[0;32m\]" NO_COLOR="\[\033[0m\]" #PS1="[\u@\h \W]\$" export PS1="[\u@\h $YELLOW\W$NO_COLOR]$GREEN\$(parse_git_branch)$NO_COLOR\$ "   Here's an output log for when I try to login to the user the works properly ssh -vvv ubuntu@server:   Here's an output log for when I try to login to the user the doesn't work properly ssh -vvv adam@server:
36638
My editor requires me to have a non-white background in my code listings. In order to make my code listings look nicer, I use the literate setting of listings to change underscores (which are very wide in the T1 font encoding) into narrower rules. Since I want the reader to be able to copy code from the PDF into a text editor and get syntactically valid code out, I am currently inserting an "invisible" textual underscore in addition to the rule.  I make the underscore invisible by using \textcolor to make it the same color as the non-white code listing background. However, this doesn't work when I typeset code with \lstinline where the background is white.  Thus I want the color of the underscore to change: In the lstlisting environment it should be grey, and in \lstinline it should be white. How do I achieve this?  Minimal Working Example:  \documentclass{article} \usepackage[T1]{fontenc} \usepackage{color,listings} \lstset{backgroundcolor=\color[rgb]{0.85,0.85,0.86},         literate={_}{\niceunderscore}1} \newcommand{\niceunderscore}{%   % Invisible underscore that can be copied in the PDF:   \makebox[0pt][l]{\makebox[3pt][c]{%     \textcolor[rgb]{0.85,0.85,0.86}{\_}}}%   % Visible, noncopyable rule:   \rule[-0.4pt]{3pt}{0.4pt}} \begin{document} This is what \lstinline+foo_bar+ looks like: \begin{lstlisting} foo_bar \end{lstlisting} \end{document}     As you can see, the underscore is visible as a grey character below the black rule in the inline text, but in the lstlisting environment, it is invisible like I want it to be.
53615
I've noticed this on occasion with a variety of applications. I've often thought it was because the output was cancelled early (ctrl+c, for example) or something similar, and zsh is filling in a new line character. But now curiosity has gotten the best of me, since it doesn't seem to do this in bash.   zsh    bash    The Sequence program is something I pulled from a book while reading on Java certifications and just wanted to see if it would compile and run. I did notice that it does not use the println() method from the System.out package/class. Instead it uses plain old print().  Is the lack of a new line character the reason I get this symbol?
60909
So, when I cat /dev/input/mouse0 in a TTY, move the mouse around a bit, and then ctrl-z to stop cat, my terminal characters are all messed up.  Almost every single character gets swapped out for another character in the ASCII character set.  This same situation occurs when I execute this in Python 3.2:  print('\033[1;12mTest.\033[1;m')   The the same symptom does not appear on a shell in the GUI, only on the virtual terminals.  The problem does not go away if I log out.  I suspect that a certain escape code (which may be contained within the Python code) is remapping the ASCII byte codes to the character representations, but that is just a guess.  What is happening and how do I undo it?
22020
I can use the "script" command to record an interactive session at the command line.  However, this includes all control characters and colour codes.  I can remove control characters (like backspace) with "col -b", but I can't find a simple way to remove the colour codes.  Note that I want to use the command line in the normal way, so don't want to disable colours there - I just want to remove them from the script output.  Also, I know can play around and try find a regexp to fix things up, but I am hoping there is a simpler (and more reliable - what if there's a code I don't know about when I develop the regexp?) solution.  To show the problem:   spl62 tmp: script Script started, file is typescript spl62 lepl: ls add-licence.sed  build-example.sh  commit-test         push-docs.sh add-licence.sh   build.sh          delete-licence.sed  setup.py asn              build-test.sh     delete-licence.sh   src build-doc.sh     clean             doc-src             test.ini spl62 lepl: exit Script done, file is typescript spl62 tmp: cat -v typescript Script started on Thu 09 Jun 2011 09:47:27 AM CLT spl62 lepl: ls^M ^[[0m^[[00madd-licence.sed^[[0m  ^[[00;32mbuild-example.sh^[[0m  ^[[00mcommit-test^[[0m         ^[[00;32mpush-docs.sh^[[0m^M ^[[00;32madd-licence.sh^[[0m   ^[[00;32mbuild.sh^[[0m          ^[[00mdelete-licence.sed^[[0m  ^[[00msetup.py^[[0m^M ^[[01;34masn^[[0m              ^[[00;32mbuild-test.sh^[[0m     ^[[00;32mdelete-licence.sh^[[0m   ^[[01;34msrc^[[0m^M ^[[00;32mbuild-doc.sh^[[0m     ^[[00;32mclean^[[0m             ^[[01;34mdoc-src^[[0m             ^[[00mtest.ini^[[0m^M spl62 lepl: exit^M  Script done on Thu 09 Jun 2011 09:47:29 AM CLT spl62 tmp: col -b &lt; typescript  Script started on Thu 09 Jun 2011 09:47:27 AM CLT spl62 lepl: ls 0m00madd-licence.sed0m  00;32mbuild-example.sh0m  00mcommit-test0m         00;32mpush-docs.sh0m 00;32madd-licence.sh0m   00;32mbuild.sh0m          00mdelete-licence.sed0m  00msetup.py0m 01;34masn0m              00;32mbuild-test.sh0m     00;32mdelete-licence.sh0m   01;34msrc0m 00;32mbuild-doc.sh0m     00;32mclean0m             01;34mdoc-src0m             00mtest.ini0m spl62 lepl: exit  Script done on Thu 09 Jun 2011 09:47:29 AM CLT
54444
One of my friends, a graphic designer told me recently that sometimes colors in Photshop look slightly different than the ones rendered in browser.  I know it is possible when you save a file and then use it on a website due to palettes, but he uses given color in PS, for example #b81e1e, then he creates a DOM element and sets its background to #b81e1e and the color is rendered differently in browser than in PS (I guess it's not that subtle as he can easily spot it). It's not a regular thing and it doesn't happen always, but he states it happened to him a few times, although he can't really tell me with witch colors.    Is it even possible? Because I have never really heard about anything like this &amp; nothing like this ever happened to me...
64487
OS X terminal is not using colors for highlighting output from different commands, for example ls.   When compared with other systems like Ubuntu, this is a big loss of accessibility/productivity.  What solutions do I have to improve this experience? For the moment I found only this guide for  but I am looking for a more complete solution.
64134
When I try to colorize the bash prompt like this:  export PS1="\e[0;31m[\u@\h \W]\$ \e[m "   it breaks the carriage return (instead of going to a new line when line is full, it starts in the same line and erases the input text).  If I remove the color sequence it works fine. I use Ubuntu 11.10 and terminal (guake has the same bug too).
72546
when I get a fresh terminal, my prompt says   (base) ~&gt;    The (base) part is something that seems new. Was this added during a recent update? How do I get rid of it? There is one piece of customization in my dot .profile, namely  export PS1="\[\e[32;1m\]\w&gt; \[\e[0m\]"   I also installed Conda recently, which might be related to that.  How do I remove  (base) ?