A string of characters displayed by interactive shells to signal the shell is waiting a user input. The prompt can be used to display variables and data about the enviornment.
41
votes
8answers
28k 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-line, because color makes the output more useful and intuitive.
What are some good ...
25
votes
4answers
1k 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.
...
16
votes
2answers
4k 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 ...
16
votes
2answers
1k 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 ...
13
votes
1answer
2k 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 ...
12
votes
2answers
257 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 ...
12
votes
2answers
571 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.
10
votes
3answers
3k 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 ...
8
votes
2answers
704 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, ...
7
votes
4answers
2k 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 ...
7
votes
4answers
538 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
2answers
1k 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 ...
7
votes
3answers
399 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
2answers
1k 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 ...
6
votes
3answers
603 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
361 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
139 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
3answers
268 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
4answers
600 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 ...
5
votes
2answers
472 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 ...
5
votes
1answer
2k 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 ...
5
votes
5answers
299 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
1answer
329 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
...
5
votes
3answers
974 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 ...
5
votes
1answer
265 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
1answer
288 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 ...
4
votes
5answers
264 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. ...
4
votes
2answers
107 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 ...
4
votes
2answers
304 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
3answers
128 views
What process is running before I even get a prompt?
When I log in to a specific server I see the following:
Note that I get get Last login: ... information but no prompt. I hit Ctrl+C and only then do I get my prompt, thus proving that my username ...
4
votes
2answers
194 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 ...
4
votes
1answer
170 views
terminal - having “$” instead of MyComputer:~ me$
Right now in my MacOS X terminal I have MyComputer:~ me$ before all the commands.
In some videos I saw they have just $ - that's much less clutter, how is it done?
4
votes
3answers
494 views
Colored text set up with PS1 and colored output from commands mess each other up
I have PS1 that ends with an opening color sequence (like \[\e[0;32m\]) to have all text in the terminal colored (green in this case). However, when I use a command such as ls (which is aliased to ls ...
4
votes
2answers
170 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 ~ $
4
votes
1answer
1k views
Printing (saving) the last bash input command
How can I get the last executed command from bash? I know that !!:p prints the last command, but it seems I can't use that anywhere except the bash prompt. I tried echo !!:p but it prints
...
4
votes
2answers
76 views
Bash Command (History) Number In PS1
I am a noob in bash to be honest. I have Googled around and cannot find an answer to this:
history lists previous commands and their number e.g.
$ history
286 clear
I want to be able to see the ...
4
votes
1answer
353 views
Re-escape brackets in PS1
As others have pointed out, color codes in PS1 should be bracketed by \[ and \] to avoid them taking up horizontal space. I've added the necessary code to .bashrc:
highlight()
{
if [ -x ...
3
votes
3answers
576 views
Is there a way to make the prompt definition multiline?
This is my current prompt definition:
PS1=$'%F{063}%1~%f %(1v.%F{099}%1v %f.)%F{063}%%%f '
RPROMPT='$VIMODE %m'
and I'm working on integrating this. Basically I'm starting to find it very ...
3
votes
4answers
482 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 ...
3
votes
2answers
983 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: ...
3
votes
2answers
574 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:
...
3
votes
5answers
2k 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
}
...
3
votes
2answers
130 views
How can I display the time when a command was executed in my bash prompt?
Currently my bash prompt looks like this
$ echo $PS1
# \[\e[34m\][\t]\[\e[0m\] \[\e]0;\w\a\]\[\e[34m\]\u@\h: \[\e[34m\]\w\[\e[0m\]\n$
$
The problem is that \t will only display the time when the ...
3
votes
2answers
99 views
Modify prompt based on value
Suppose I have an environment variable defined in .bash_profile like this:
PS1='\[\e[31;1m\][\u@\h \T \w] \[\e[0m\]'
This variable makes my Linux prompt show certain information, like thes:
...
3
votes
3answers
83 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 ...
3
votes
2answers
2k views
change prompt color depending on user or root in zsh
in zsh you can have a %# in your PS1 (or whatever PROMPT variable) which basically means display % if user or display # if root. I'm wondering if there is any way to affect this so that the % or # ...
3
votes
1answer
66 views
Prompt for confirmation for every command
I'm writing a pretty ad-hoc install script for some thing. No much control constructs, basically just a list of commands. I'd like the user to confirm each command before it gets executed. Is there a ...
3
votes
2answers
665 views
How to script /etc/issue?
I would like to pipe my tty number through figlet (ASCII generator) for the /etc/issue (message shown before login). Obviously this means I can't just update it from /etc/rc.local.
On my system ...
3
votes
1answer
192 views
ssh behavior for root and non-root user
When I ssh as root to a remote machine, the command output looks like this:
root@Machine:/current/path#:
However, if it's a non-root user, all I see is:
$
How can I get the same behavior as for ...
3
votes
1answer
806 views
How to make my Linux tcsh prompt bold?
Greeting all,
I am attempting to make my Linux tcsh prompt bold. However I'm failing miserably.
I know about escape codes and I can successfully make echo'ed output bold, but I can't seem to do it ...
