I've never coloured my bash prompt before, but after a quick googling I'm running: PS1='\[\033[0;31m\]\u@\H:\[\033[0;33m\]\w\$\[\033[00m\] '  giving me red username/host followed by yellow working directory. Further googling has suggested to me that the colours available are fairly limited. #!/bin/bash # #   This file echoes a bunch of colour codes to the  #   terminal to demonstrate what's available.  Each  #   line is the color code of one forground color, #   out of 17 (default + 16 escapes), followed by a  #   test use of that color on all nine background  #   colors (default + 8 escapes). #  T='gYw'   # The test text  echo -e &quot;\n                 40m     41m     42m     43m\      44m     45m     46m     47m&quot;;  for FGs in '    m' '   1m' '  30m' '1;30m' '  31m' '1;31m' '  32m' \            '1;32m' '  33m' '1;33m' '  34m' '1;34m' '  35m' '1;35m' \            '  36m' '1;36m' '  37m' '1;37m';   do FG=${FGs// /}   echo -en &quot; $FGs \033[$FG  $T  &quot;   for BG in 40m 41m 42m 43m 44m 45m 46m 47m;     do echo -en &quot;$EINS \033[$FG\033[$BG  $T  \033[0m&quot;;   done   echo; done echo  Which shows red/green/yellow/blue/pink/cyan/white, with bold variants. However, if I run ls, the output is much more appealing, with nice pastelly-shades.  .gz files, for example show as a slightly orangey-pastelly pinky red, #d74646 / rgb(215,70,70) How can I access colours like that for my prompt.  And if I can't - why can't I? This is all using CentOS viewed via PuTTY 0.73 from my Windows 10 laptop. Thank you!
67951
I used several colors in my PS1 prompt such as   \033]01;31\] # pink \033]00m\]   # white \033]01;36\] # bold green \033]02;36\] # green \033]01;34\] # blue \033]01;33\] # bold yellow   Where can I find a list of the color codes I can use?  I looked at  but it didn't answer my question about a list of the actual codes.  It would be nice if there was a more readable form also.  See also
31135
I'm currently logged into a server via ssh with ssh -Y and running a tmux session. If I start vim and run :colorscheme elflord the color scheme is changed. (Although the colors are not exactly what I would expect although they are I think 256 color. If I create a ~/.vimrc file and put a single line colorscheme elflord  in it then when I run vim it shows no color (just white text) and I cannot change the color with the :colorscheme command.
26646
I need  to use the less command with the syntax highlighting of the vim command for python, C, bash and other languages.  How do I apply syntax highlighting colors according to vim colors for less command?
27410
I am using  to show the branch name in gnome terminal (Ubuntu 15.10) when working in a git repository. Based on the above I now have the below in my ~/.bashrc file:  # uncomment for a colored prompt, if the terminal has the capability; turned # off by default to not distract the user: the focus in a terminal window # should be on the output of commands, not on the prompt #force_color_prompt=yes    ...  # Add git branch if its present to PS1 parse_git_branch() {  git branch 2&gt; /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } if [ "$color_prompt" = yes ]; then  PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' else  PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ ' fi unset color_prompt force_color_prompt   As a result I now get:    so it works. But why has the coloring of my user@host been removed? And I would also expect that the branch name should be colored. Before it looked like this:    UPDATE: I have now tried this guide instead:    adding this to .bashrc:  parse_git_branch() {      git branch 2&gt; /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "   and that works:    Notice in .bashrc I also have this (default):  # uncomment for a colored prompt, if the terminal has the capability; turned # off by default to not distract the user: the focus in a terminal window # should be on the output of commands, not on the prompt #force_color_prompt=yes   I have yet to find the reason why that snippet gives the correct result and the other version does not. Any input on this?  Here is the version of my .bashrc that has the old snippet enabled that does not work:
94079
(For code that is for Ruby on Rails questions on SO)  I have some output in my terminal.  When things work I get a green status line, e..g  Using /Users/durrantm/.rvm/gems/ruby-1.9.3-p125 with gemset dmworkflow   I would like to be able to show that in SO in green, which is the way is appear in the terminal.  This would also be useful for manual red/green coloring of passing/failing tests that people would want to colorize to be easier to read.
37894
There's already  which point to various executables (with or without full path). , not necessarily the name of the executable (in xterm it's xterm-color, and in gnome-terminal it's xterm-256color). Is there a variable which is expected to contain the name or path of the executable to use as the default terminal in Linux? (Or Arch Linux, if there is a custom convention.) Maybe this is nonsensical, since GUI programs are rarely spawned from shells which know of these variables…
47349
Sometimes when I simply type a valid command like 'find ...', or anything really, I get back the following, which is completely unexpected and confusing (... is command name I type): sh: $'\302\211...': command not found  There is some corruption going on I think. I don't use color in my prompt, I am using the Bash shell in POSIX mode as sh (chsh to /bin/sh and so on - $SHELL is sh). What is going on and why does this keep happening? Anything I can debug? I think this is more of an xterm issue than sh, or at least a combination of the two. Files, for context: My /etc/profile, as distributed with Arch Linux x86-64: # /etc/profile  #Set our umask umask 022  # Set our default path PATH=&quot;/usr/local/sbin:/usr/local/bin:/usr/bin&quot; export PATH  # Load profiles from /etc/profile.d if test -d /etc/profile.d/; then         for profile in /etc/profile.d/*.sh; do                 test -r &quot;$profile&quot; &amp;&amp; . &quot;$profile&quot;         done         unset profile fi  # Source global bash config if test &quot;$PS1&quot; &amp;&amp; test &quot;$BASH&quot; &amp;&amp; test -r /etc/bash.bashrc; then         . /etc/bash.bashrc fi  # Termcap is outdated, old, and crusty, kill it. unset TERMCAP  # Man is much better than us at figuring this out unset MANPATH  My /etc/shrc follows below. It's something I created as a way to have sh parse some file on startup, for a non-login shell; it is achieved using ENV variable set in /etc/environment with the line ENV=/etc/shrc: PS1='\u@\H \w \$ ' alias ls='ls -F --color' alias grep='grep -i --color' [ -f ~/.shrc ] &amp;&amp; . ~/.shrc  My ~/.profile, I am launching X when logging in through first virtual tty: [[ -z $DISPLAY &amp;&amp; $XDG_VTNR -eq 1 ]] &amp;&amp; exec xinit -- -dpi 111  My ~/.xinitc, as you can see I am using the system as a Virtual Box guest: xrdb -merge ~/.Xresources  VBoxClient-all  awesome &amp;  exec xterm  And finally, my ~/.Xresources, no fancy stuff here I guess: *faceName: Inconsolata *faceSize: 10 xterm*VT100*translations: #override &lt;Btn1Up&gt;: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)  xterm*colorBDMode: true xterm*colorBD: #ff8000 xterm*cursorColor: S_red  Since ~/.profile references among other things /etc/bash.bashrc, here is its content: # # /etc/bash.bashrc #  # If not running interactively, don't do anything [[ $- != *i* ]] &amp;&amp; return  PS1='[\u@\h \W]\$ ' PS2='&gt; ' PS3='&gt; ' PS4='+ '  case ${TERM} in   xterm*|rxvt*|Eterm|aterm|kterm|gnome*)     PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf &quot;\033]0;%s@%s:%s\007&quot; &quot;${USER}&quot; &quot;${HOSTNAME%%.*}&quot; &quot;${PWD/#$HOME/~}&quot;'                                                              ;;   screen)     PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf &quot;\033_%s@%s:%s\033\\&quot; &quot;${USER}&quot; &quot;${HOSTNAME%%.*}&quot; &quot;${PWD/#$HOME/~}&quot;'     ;; esac  [ -r /usr/share/bash-completion/bash_completion   ] &amp;&amp; . /usr/share/bash-completion/bash_completion  I have no idea what that case statement does, by the way, it does look a bit suspicious though, but then again, who am I to know.
91964
I see one other   with the same problem:  Instead of two kinds of blue (normal and bright/bold) I have only one, very hard-to-read so-called "bold blue". Normal blue is even worse, almost invisible.   I don't want to change LS_COLORS. I do want directories in blue, but in a brighter one. I don't want them in magenta or green.  In dircolors' output I see dozens of extensions (tar, tgz, mp3) coding for bright red or magenta. And something as fundamental as a directory gets completely lost in it's midnight blue!    It is already set to bright:  `DIR 01;34 # directory`   or with dircolors -b:    LS_COLORS='...di=01;34...'   In XTerm I can set *VT100*color12: SkyBlue2 in the app-defaults/ file. But for the console? The kernel only gives me 16 predefined ANSI colors!  Do I have to recompile the kernel to change these RGB definitions for the console? This navy blue must be coded somewhere!     /* added after 1st answer */  I tried echo -en "\e]PCrrggbb" as proposed: this works! This is really special - the bracket is the other way round. And "should be OSC" in the man page...thank you!   The link in dirkt's answer also has setvtrgb as a second solution. Number salad, but no escape codes.    Do these two methods amount to the same?
51125
I have code like this in php:  header("Content-Type: text/plain"); exec("/bin/bash -c 'ls --color=always'", $result); echo implode("\n", $result);   and I've got result (escape is not visible)  Makefile README Yann Tiersen - Comptine d'un autre ete L'apres midi.mp3 bush-src.js bush.js bush.min.js [0m[01;34mcgi-bin[0m config.json [01;34mcss[0m favicon.ico foo.png index.php [01;34mlib[0m ls.txt test.php test.php~ [01;32mtest.txt[0m   It show ANSI escape codes for directories and executable files, but when I call from command line  php -r "exec('bash -c \"ls --color=always\"', \$result);echo implode(\"\\n\", \$result);" | less   I've got this:  bush.js bush.min.js bush-src.js ESC[0mESC[01;34mcgi-binESC[0m config.json ESC[01;34mcssESC[0m favicon.ico ESC[01;35mfoo.pngESC[0m index.php ESC[01;34mlibESC[0m ls.txt Makefile README test.php test.php~ ESC[01;32mtest.txtESC[0m ESC[00;36mYann Tiersen - Comptine d'un autre ete L'apres midi.mp3ESC[0m   png and mp3 have ANSI escapes codes, why php exec from webpage don't give that as return?
83042
Is there a way to copy the currently written content of the bash prompt? Say I wrote:  ping www.google.com   so that the lines in terminal looks like:  petr@sova:~$ ping www.google.com   and didn't hit return yet. I want to copy that text to clipboard. Is that possible?  The usual usecase would be hitting up several times and finding a command which I want to copy.
99673
Note: I reworked the question to clarify the issues. This is a trivial question that can be answered in several parts because the question has several attributes.  Unfortunately, the question may be reworked when the person asking the question apprehends (knows) some parts of the answer as well as the structure of the question.  Therefore, the question is presented from a different point of view than the original one.  How to change the color setting¹ of the Linux console, using a shell utility? How to change the color setting¹ of a terminal emulator, using a shell utility?  Originally, I wanted to change the background color of the Linux console during the execution of a shell script. The following proposition works as I wanted.  #!/bin/sh  # set the background color of the terminal tput setab 6 clear  printf "%s\n" 'background: cyan'  # do some tasks  cd /usr/src/initramfs pwd ls -l  # the background of the shell output is cyan   Nonetheless, someone may encounter several glitches (or difficulties).   For instance, if the screen is not cleared, the background color is only applied to the text output, during a shell script execution. If the command tput setab 6 is submitted with the command line and the screen is not cleared, the background color is only applied to a small portion of the output text. If the command tput setab 6 is submitted on the command line and the screen is cleared, the background color is applied to the full screen but only persists until another command is submitted. [...]  ¹ background color
35812
I run a script in terminal and the output printed in the terminal I also save in a text file. How can I display that text in Gedit colored similar to what I can see in the terminal? I thought there could be a plugin. Update I might not have been as clear as I planed, so I would like to see similar coloring changes in the plain text file as appears in terminal, not for shell scripts but if I have an error message (e.g. compiler error) than those line to be differentiated from other printouts in terminal. $ rosrun my_pkg my_node &gt;&gt; terminal_printout Update 2 My gedit version is 3.10.4 ii  libgtksourceview-3.0-1:amd64   3.10.2-0ubuntu1 amd64 sared libraries for the GTK+ syntax highlighting widget ii  libgtksourceview-3.0-common    3.10.2-0ubuntu1 all common files for the GTK+ syntax highlighting widget
44046
There are a number of tutorials/posts online (e.g. ) about how to customize your prompt in bash by setting PS1.  Is there a way to customize the color/bolding of the command I type?    In other words, as an example lets say that I wanted a green prompt, a bold blue command, and then output in whatever colors would be default.  In the example below, I already know how to make "joe&gt;" show as green, blue, bold, whatever by setting PS1.  But is there a way I can I make git status show as bold for example?  joe&gt; git status # On branch master # Your branch is ahead of 'origin/master' by 2 commits. # ...
58001
I have followed the instructions  and in the  that is provided there. However nowhere does it appear to say how I can change the colours of the different parts, because currently I set it to:  PS1='${debian_chroot:+($debian_chroot)}[\t] \u@\h:\w\$ '   But the text is still all white, how could I perhaps make the numbers for the time green, and my username and computer name light blue? I am running Ubuntu GNOME 15.04.
10011
In the below link        the author highlights anything which is important using a greyish color background. For example, if you see Equation 1.5.3 (which on page 22 of the book) it is highlighted in grey. I would like to know the TeX commands for producing similar output.
51621
On my console the color for directories is such a blue, that it is hard to read on a dark background.  How can I change the color definitions for ls?
40080
I am in the process of colorizing my terminal’s PS1.  I am setting color variables using tput; for example, here’s purple:  PURPLE=$(tput setaf 125)   Question:  How do I find the color codes (e.g. 125) of other colors?  Is there a color table guide/cheat sheet somewhere?  I’m just not sure what 125 is … Is there some way to take a hex color and convert into a number that setaf can use?