A string of characters displayed by interactive shells to signal the shell is waiting a user input.

learn more… | top users | synonyms

79
votes
8answers
93k views

Colorizing your terminal and shell environment?

I spend most of my time working in Unix environments and using terminal emulators. I try to use color on the command-lin, because color makes the output more useful and intuitive. What are some good ...
40
votes
2answers
15k views

Awesome symbols and characters in a bash prompt

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 ...
26
votes
5answers
3k views

Better way of accepting variations of ‘Yes’ from a shell prompt

Usability testing of a shell script I wrote found that people had different expectations on how to answer a question that expected ‘yes’ as the answer. See variations in the below code example. ...
21
votes
1answer
4k views

How can I tell if I'm in a tmux session from a bash script?

I like to keep my bash_profile in a git repository and clone it to whatever machines I have shell access to. Since I'm in tmux most of the time I have a user@host string in the status line, rather ...
18
votes
4answers
5k views

make my zsh prompt show mode in vi mode

I use bindkey -v (for bash-ers set -o vi I think that works in zsh too) or vi(m) mode. but it bugs me that I don't have any visual cue to tell me whether I'm in insert mode or command mode. Does ...
18
votes
2answers
2k views

Display stuff below the prompt at a shell prompt?

Lets's say my prompt looks like this (the _ represents my cursor) ~ % _ Is there any way I could make it look like this ~ % _ [some status] The question was originally about zsh, but now has ...
17
votes
5answers
2k views

Why do I sometimes get repeatedly prompted with “>” in the terminal?

Alright, when I run certain commands the wrong way, (misspelled, etc.) The terminal outputs this: > instead of computername:workingfolder username$, and when I type enter it goes like this: > ...
15
votes
2answers
2k views

Can I configure bash to execute “clear” before every command typed in the console?

I would like to configure bash to execute clear command every time I type some command in the terminal (before executing my command). How can I do that? I'm using Debian Linux.
14
votes
3answers
1k views

Using variables to store terminal color codes for PS1?

In my .bashrc, I use ANSI terminal color codes to colorize various bits. It looks like this: PS1='\u@\h:\w\[\033[33m\]$(virtual_env)\[\033[32m\]$(git_branch)\[\033[0m\]$ ' where virtual_env and ...
13
votes
5answers
569 views

Stateful bash function

I’d like to implement a function in Bash which increases (and returns) a count with every call. Unfortunately this seems non-trivial since I’m invoking the function inside a subshell and it ...
13
votes
2answers
2k views

Display command in xterm titlebar

My Bash Prompt is currently setting the xterm titlebar using the following sequence: PS1='\033]0;\u@\h>\w\007' Is there an easy way to display the current command in the titlebar. For example, ...
12
votes
2answers
404 views

Possible to configure Login TTY over Audio device (Morse code or similar)?

One of the most miserable aspects of my day job is the need to occasionally investigate problems with machines scattered in remote locations all over the world that don't have network access to the ...
11
votes
1answer
477 views

Clear old prompt lines in bash to save scroll space

My terminal theme used to be like this, But I thought the prompt wasted so much space. And later I got an idea that I could clean the prompt every time I ran a command. I was using bash, one of ...
10
votes
1answer
949 views

Why is my bash prompt getting bugged when I browse the history?

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 ...
9
votes
2answers
2k views

How do you make RPROMPT in zsh update itself on every enter?

My RPROMPT is set to display svn info using vcs_info. It reads RPROMPT=${vcs_info_msg_0_}. vcs_info is called using precmd(). However, RPROMPT doesn't update when I change directories. It works only ...
9
votes
3answers
545 views

How to include commands in Bash's PS1 without breaking line length calculation?

Tonin pointed out a bug in my default prompt. Minimal example: Set PS1: PS1='$(exit_code=$?; [[ $exit_code -eq 0 ]] || printf %s $(tput setaf 1) $exit_code $(tput sgr0) " ")$ ' At this point, the ...
8
votes
4answers
8k views

How to make the terminal display user@machine in bold letters?

I have seen in some screen-shots (can't remember where on the web) that the terminal can display the [username@machine /]$ in bold letters. I'm looking forward to getting this too because I always ...
8
votes
2answers
4k views

How can I change what's displayed at a login shell?

I'm getting more familiar with tweaking the way things look in a shell via the prompt (.bashrc), but I'm now trying to change the initial stuff displayed when I first log in. On my EC2 instance, this ...
8
votes
3answers
1k views

What color codes can I use in my PS1 prompt?

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 ...
8
votes
4answers
2k views

Abbreviated current directory in shell prompt?

vim has a really nice feature which it utilizes in its paths when they're a bit long: It abbreviates the path to the document in the tab at the top. Is there a way to do something similar to this ...
8
votes
1answer
251 views

Echoing progress from a background process without hijacking prompt

Consider the simple script hello: #!/bin/bash echo 'hello world!' Now from bash if I try to run this in the background: $ hello & [1] 12345 $ hello world! █ <--- prompt is stuck here until ...
8
votes
6answers
4k views

Bash: Display exit status in prompt:

GREEN="\e[1;32m" RED="\e[1;31m" NONE="\e[m" get_exit_status(){ es=$? if [ $es -eq 0 ] then echo -e "${GREEN}${es}${NONE}" else echo -e "${RED}${es}${NONE}" fi } ...
8
votes
1answer
5k views

How to change tty login prompt?

To be clear, I am not referring to /etc/issue (shown before the prompt) or /etc/motd (shown after login), but the prompt itself, which is currently hostname login: For good measure, I am running ...
8
votes
3answers
2k views

Change the PS1 color based on the background color?

I learned that I can change the format of PS1, especially the color of the string. Then, is it possible to change the color based on the background color of the shell? Or, how can I detect the ...
7
votes
4answers
650 views

Changing the bash prompt

Where is the setting that determines what the bash prompt looks like? Specifically on Arch, but I'm sure others would like to know for other distros too if it's different. Speficially I'd like to use ...
7
votes
3answers
621 views

Can I highlight the current prompt line in zsh?

Is it possible to highlight (set a background colour) for the whole line of the prompt in zsh? In my emacs config I have the line on which the cursor sits a slightly different colour to the window ...
6
votes
5answers
2k views

How to make bash put prompt on a new line after cat command?

What I get: host:~ user$ cat example.txt some texthost:~ stas$ What I want to get: host:~ user$ cat example.txt some text host:~ stas$ Is there a way I can make cat behave like this? I'm using ...
6
votes
1answer
478 views

Why does this PS1 value cause unexpected behaviour? [duplicate]

Possible Duplicate: Why is my bash prompt getting bugged when I browse the history? I have set my PS1 variable in .bashrc to be the following: PS1='\e[35m[\W]:\e[0m ' It achieved what it ...
6
votes
3answers
1k views

bash PS1 setup

I'm trying to make PS1 configured as follows. Green="\[\e[32;1m\]" Red="\e[0;31m" Purple="\e[0;35m" STARTCOLOR="\[\e[40m\]" ENDCOLOR="\[\e[0m\]" export PS1="$STARTCOLOR$Green\u@$Purple\h ...
6
votes
3answers
641 views

Terminal prompt not wrapping correctly

I have an issue where if I type in very long commands in bash the terminal will not render what I'm typing correctly. I'd expect that if I had a command like the following: username@someserver ...
6
votes
2answers
1k views

Bash $PROMPT_COMMAND messing up scroll history display

I set up a PROMPT_COMMAND to display the current branch while I'm in a git repo. The relevant part of my .bashrc is: export PS1=" \[\033[34m\]\$\[\033[0m\] " export ...
6
votes
3answers
659 views

Bash history number not starting at 1?

I was customizing my bash prompt (I'm on OS X 10.7) when I came across something strange. Within my prompt I included !, which should give me the history number. However the history number always ...
6
votes
1answer
198 views

How can I output “temporarily” to the shell, like zsh tab completion does?

In zsh shell, when you hit Tab twice to get tab completion, your options are displayed below your prompt. But when you make a selection, the options disappear. I have a little script that outputs ...
5
votes
5answers
361 views

Conflict between my prompt definition and cat in zsh

I have a file on a remote filesystem that I know has a short text string in it (a sequence of numbers in a single line). If I open the file on a text editor like nano or Emacs I can see the string. ...
5
votes
2answers
600 views

Wrap command in the prompt

Is it possible to insert a separator after the command in a prompt? This is an example: ~/Desktop: ls -al ------------------------------------- total 80 drwx------+ 6 eddie staff 204B Apr 29 ...
5
votes
2answers
853 views

Bash prompt not recognizing Unicode escapes

I'm trying to customize my Bash prompt with Unicode characters and I'm having a bit of trouble. If I try to include a Unicode character like this: $ echo ☢ | hexdump -C 00000000 e2 98 a2 0a ...
5
votes
3answers
698 views

Bash prompt that won't clobber long commands

I'm trying to set up a bash prompt for - hostname(screen#):directory$ which is coloured green if the last command completed successfully, red if not. This is what I have so far, which actually does ...
5
votes
2answers
5k views

Colored Prompt in KornShell

According to this StackOverflow post, it is possible have a colored prompt in KornShell. I have not been able to figure out how to do this. I am able to use color: echo -e "\033[34mLinux\033[00m" ...
5
votes
1answer
2k views

In Bash, why is PROMPT_COMMAND set to something invisible?

On RHEL6 and CentOS 6, /etc/bashrc sets PROMPT_COMMAND here: case $TERM in xterm*) if [ -e /etc/sysconfig/bash-prompt-xterm ]; then PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm ...
5
votes
3answers
228 views

How to customize PS1 properly?

I customized my bash with this in my bashrc export PS1="\e[0;36m\h\e[m \e[0;33m\w/\e[m \e[0;31m\n\$ →\e[m " So I get something like this (with colors) : Ahuri ~/Public/ $ → But I am having ...
5
votes
5answers
513 views

Would it be possible to jump between prev/next command prompts?

I'm using zsh in OS X Terminal.app and for quite a while, I've been longing for a way to jump back and forth between prev/next prompts in the terminal's output. One convenience with this would be to ...
5
votes
2answers
301 views

Display Non-Zero Return Status in PS1

I want to include the return status in my prompt. (Easy add '$? ', right?) However, I only want the status returned (and trailing space) if non-zero. Example: sd ~ $ false 1 sd ~ $ true sd ~ $
5
votes
3answers
386 views

change prompt formatting based on cwd

I use tcsh. I'd like to have my prompt formatting (coloring/highlighting) change based on the directory I'm in, or other critical aspects of my environment. I'm not enough of a shell hacker to know ...
5
votes
2answers
56 views

Long-generating Bash prompt wraps incorrectly when I start typing

I have a Bash prompt that takes a while (~100-200ms) to generate, because it includes Git working tree status that takes some time to compute. Sometimes I start typing a command before it appears, but ...
5
votes
1answer
405 views

history list in bash always truncated to 5000 lines at new login

Similar to the 5000 line limitation problem when first thing in .bashrc I have export HISTSIZE=10001 and export HISTFILESIZE=$HISTSIZE My users do not have ~/.inputrc files and the system-wide ...
4
votes
4answers
1k views

Which stream does Bash write its prompt to?

I am trying to redirect all output from bash (prompt, user input, results) to a file Example: /bin/bash > file.txt 2>&1 I thought that would work, but I'm not getting the prompt. Can ...
4
votes
2answers
1k views

Admin user not showing directory path in console prompt, only $

I have an Ubuntu server that I administer through ssh. When I login as root I get a full path in the prompt, like /var/www. I created a user with sudo privileges for the purpose of administration. ...
4
votes
2answers
7k views

executing if-statement from command prompt

In bash I can do the following: if [ -f /tmp/test.txt ]; then echo "true"; fi However, if I add sudo in front, it doesn't work anymore: sudo if [ -f /tmp/test.txt ]; then echo "true"; fi -bash: ...
4
votes
2answers
970 views

Strange Character in my Bash prompt?

I'm somewhat new to Bash prompts, but I was finally able to get things somewhat working. However, I have a strange character at the beginning of my prompt: Here's my actual PS1 prompt: ...
4
votes
3answers
1k views

How to customize .bashrc to configure command prompt?

Is there an easy way to change my Bash prompt to modify the colors and what text is displayed? I've heard that this is done in .bashrc, but I haven't found any nice, easy ways of modifying it. How are ...