My terminal prompt is set using the following configuration in my .profile file:  # Prompt GREEN=$(tput setaf 2) LIME_YELLOW=$(tput setaf 190) MAGENTA=$(tput setaf 5) WHITE=$(tput setaf 7) NORMAL=$(tput sgr0) PS1="\[${WHITE}${MAGENTA}\]\u\[${WHITE}@${GREEN}\]\h \[${LIME_YELLOW}\]\W \[${WHITE}${NORMAL}\]$ "   Generally speaking it works fine but sometimes I end up with an off-by-one error. After a running a few commands and then accessing the history using the up key, some characters seem to be getting garbled. For example:  matt@laptop ~ $ git log   becomes  matt@laptop ~ $ gitlog   or:  matt@laptop ~ $ ssh desktop   becomes  matt@laptop ~ $ssh desktop   The incorrectly displayed command executes normally and appears in history normally too.
31858
Often when I start looking at history of commands some of the characters from a command displayed aren't erased, for example:  What's happening:  prompt$ some_command prompt$ some_commanother_command   What should have happened:  prompt$ some_command prompt$ another_command   I can't erase those characters and bash ignores them when executing the command. They also disappear when a new prompt is being displayed (after pressing Enter for example).  I asked other people who work on Linux at my workplace and they said that they have that problem sometimes too, but they didn't have an idea on how solve that issue.  I have Ubuntu 11.10 and I'm using guake. Here is my PS1:  \e[0;31m\u \A ${PWD##*/}\e[0;32m$(parse_git_branch)\e[0;31m$\e[m   where parse_git_branch is  parse_git_branch () {     git name-rev HEAD 2&gt; /dev/null | sed 's#HEAD\ \(.*\)# (\1)#' }   As far as I know my colleagues have that problem even with less "fancy" PS1.
6246
If I open up a terminal (xfce4-terminal 0.6.3, but I doubt it matters) and I look at what terminal attributes are set (BASH is running in the terminal),  $ stty -a speed 38400 baud; rows 24; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0; -parenb -parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -extproc   then I have a whole bunch of terminal attributes. Fine enough. If I then take a look at what terminal I'm using:  $ tty /dev/pts/0   then, on a new tab of my terminal (which new tab happens to be /dev/pts/1) I look at the terminal attributes of my first terminal, it seems to have slightly different terminal attributes:  $ stty -a -F /dev/pts/0 speed 38400 baud; rows 24; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = &lt;undef&gt;; discard = ^O; min = 1; time = 0; -parenb -parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff -iuclc ixany imaxbel iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -extproc   Notably, the original terminal here appears to not be in canonical mode, it has no literal next special character...  So why does this happen? I'd like to be able to look at things like this to see, e.g., if modern ed uses canonical mode, but if there's a Heisenberg problem of looking at it from another terminal, I don't know how I'd do it.  So, my two main questions:   Does the terminal just appear to have different attributes when I look at it from another terminal? (e.g. is my first terminal still in canonical mode, but stty -a -F returns incorrect information?) If the terminal does really change attributes when I switch to the other terminal, how does it know? Is the 1st terminal somehow informed when I'm not directly looking at it?   P.S.: I tried this on the Linux Console also, just to make sure it wasn't a pseudo-terminal thing. Same results.
71067
I was surprised that I didn't find this question already on the site. So, today $ came up after I logged in as a new user. This was unexpected because my main user's prompt starts with username@computername:~$.  So, how do I switch from this other shell to bash?
48149
I would like the CasebashMac:bfgenv chris$ part of the following line to appear in a different color in my terminal.  CasebashMac:bfgenv chris$ python
98839
As a default, the terminal prompt shows something like:  user@system:/folder1/folder2/folder3/folder4$   the deeper you go into the filesystem, the less space is left for typing in commands. Can I change this to only show something like:  &gt;   I mean, I can just type pwd to show where I am at. ;)
60857
I just ran across a screenshot of someone's terminal:    Is there a list of all of the characters which can be used in a Bash prompt, or can someone get me the character for the star and the right arrow?
109491
The default prompt will be   root@monu dev]#   Can we change the "root@monu" part and give it a desired name?
102912
See my edit below, this is not totally a duplicate of   My reverse-search function in the CLI is broken and I don't know how to fix it back...  When I hit ctrl+r and search a command I did earlier, find it then press the right arrow key to use it, the output is broken. Here is an example:  # I reverse-searched the word "test" then pressed right arrow yoshiji@x1carbon:~/path/to/git/folder (master) $ch)`test': rake test #                                              ^^^^^^^^^^ weird output #                                                     ^ cursor right there   It also "shifts" my cursor to a different position. If I press enter, the right command is executed (rake test in this case) so it means the text displayed is not the same as what is actually executed.  I know this is most-likely related to my PS1 export in my ~/.bashrc, so here are the last lines of this file:  # Git branch in prompt. git_branch() {   branch=$(__git_ps1 2&gt; /dev/null)   if [ "$branch" = " (master)" ]; then      echo -e "\033[33m${branch}\033[00m" # yellow   elif [ "$branch" = "" ]; then      echo -e "\033[90m (no git)\033[00m" # red   else      echo -e "\033[32m${branch}\033[00m" # green   fi } PS1='\u@\h:\w$(git_branch) \$ '   This is something I wrote to displays the git branch in orange (if master branch) or else in green (or no git in gray).  Do you guys have any idea on what is causing this weird behavior?    Edit: This is a different problem from the  in the way that I am using echo -e "some string" to return a string having color+name of the git branch from the function git_branch(). Using echo -e does not escape the characters \[ and \] (try it yourself in your CLI: echo -e "\[\033[33m\]test").  Ideally, I would like to keep those conditional colors based on the branch's presence &amp; name (gray if no branch, orange if master, else green).
104203
I recently rent a VPS and generated a public/private key pair and transferred it to my server (added it there to the authorized_keys file) ...  So far on my first login via terminal on OSX I got asked for my passphrase and declined to save it to my keychain.  However my terminal won't prompt for the passphrase anymore, instead I can connect instantly via "ssh myserver.com" ...  I can't find the key in my keychain (why should I) and can't figure out why it's not asking for my passphrase!  EDIT: Ok, after a restart of my macbook I get the prompt again. One time. It seems it saves it temporarily ... I do not want that
57033
I have installed ubuntu minimal(mini.iso) on my vm. I then used recovery mode to login as root and create an account with useradd -m admin and then set a password with passwd admin.  When I login on the new account, instead of the normal prompt I only see a $ sign. If I try to tab-complete a command or file name it prints a normal tab. If I try to use the arrow keys it prints ^[[A, ^[[B, ^[[C or ^[[D. Also, ls no longer adds colors.  None of these problems were in recovery mode. How can I fix this?
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?
30397
One thing that annoys me using Linux's terminal is when I have to type a invisble password, like when you run ssh. Sometimes I mistype one or more letters and then I have to press backspace key a few times to make sure that I erased everything to start again.   I know this is not a big deal but since on the other day I found out that pressing CTRL+L "clears" the terminal I was wondering if there's a way to clear/erase the invisible password without relying on backspace or pressing enter key to try again.
43939
I have played around with PS1 and PROMPT_COMMAND in bash to create a zsh-style right side prompt. I have a solution who almost works.  The problem is that if I write a long line of input, the second line overwrites the first one. The third line will appear nicely on a new line.  Maybe some line counter are of-by-one because my cursor movement, or is this a limitation/bug?  A simple example:  export PS1="prompt&gt;\[\033[s\033[10C\]test\[\033[u\]"   Print prompt&gt;, save position, move 10 characters to the left, print test, restore position.  The prompts looks nice and works perfectly, until i write more then one line of text.  Example 1, expected behaviour:  ------------------------------------ prompt&gt;          test prompt&gt;ls        test files... prompt&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28   Example 2, current behaviour:  ------------------------------------ prompt&gt;          test prompt&gt;ls        test files... 14 15 16 17 18 19 20 21 22 23 24 253 26 27 28
98013
I have a private key set up for my github account, the passphrase to which is, I believe, stored in OS X's keychain. I certainly don't have to type it in when I open a terminal window and enter ssh git@github.com.  However, when I'm running bash over an ssh session, or locally inside a tmux session, I have to type in the passphrase every single time I attempt to ssh to github.   suggests that a similar problem exists with screen, but I don't really understand the issue well enough to fix it in tmux. There's also  which includes a fairly complicated solution, but for zsh.  EDIT:  In response to , from a local terminal I get the following output:  [~] $ echo $SSH_AUTH_SOCK /tmp/launch-S4HBD6/Listeners [~]  $ ssh-add -l 2048 [my key fingerprint] /Users/richie/.ssh/id_rsa (RSA) [~] $ typeset -p SSH_AUTH_SOCK declare -x SSH_AUTH_SOCK="/tmp/launch-S4HBD6/Listeners"   Whereas over ssh or in tmux I get:  [~] $ echo $SSH_AUTH_SOCK  [~] $ ssh-add -l Could not open a connection to your authentication agent. [~] $ typeset -p SSH_AUTH_SOCK bash: typeset: SSH_AUTH_SOCK: not found   echo $SSH_AGENT_PID returns nothing whatever shell I run it from.
93444
In terminal, the usual prompt text user@machine isn't green/blue as usual. Instead is is just white like the rest of the text. If I ssh into my server however, the colours are the same. Perhaps I've accidentally hit a button?  The settings in Edit → Profile Preferences → Colors look fine. The selected palette shown there is Linux Console.  I've tried using apt remove gnome-terminal &amp;&amp; apt install gnome-terminal but that still hasn't worked. I've also tried using the MATE Terminal method and using UXTerm but both of which are doing the same issue.
120827
I have the following prompt in bash which shows the current git branch:  PS1+="$(git_prompt)" #git_prompt is a function in my .bashrc   which works when I source the .bashrc, but not when I change the branch, so the PS1 var gets only evaluated when I source the .bashrc, but it should be evaluated every time a new prompt is displayed. How can this be accomplished with bash 4.3 ?
108921
I'd like to make commands I've typed (input) into terminal stand out from all the output.   For example:  imac:~ buster$ chmod -R g-w myfolder  imac:~ buster$ cd myfolder imac:myfolder buster$ ls -l total 0 drwxr-xr-x   9 root  admin   306 Apr 20  2010 bin drwxr-xr-x   7 root  admin   238 Apr 20  2010 include drwxr-xr-x  73 root  admin  2482 May 18 17:16 lib drwxr-xr-x   6 root  admin   204 Apr 20  2010 man imac:myfolder buster$ echo Go Giants! Go Giants!  bold jumps to mind but I'd accept a color or even highlighting the whole line...   I'm sure there's a way to do this but it's not obvious to me...  thanks!