Questions tagged [prompt]

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

Filter by
Sorted by
Tagged with
317 votes
25 answers
981k 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 options exist ...
Stefan Lasiewski's user avatar
250 votes
11 answers
160k 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 ~/...
Muricula's user avatar
  • 2,610
206 votes
8 answers
279k views

What color codes can I use in my Bash PS1 prompt?

I used several colors in my bash 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 ...
Michael Durrant's user avatar
183 votes
3 answers
76k views

Why ZSH ends a line with a highlighted percent symbol?

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 ...
jktravis's user avatar
  • 2,226
98 votes
2 answers
36k views

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

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 ...
korda's user avatar
  • 1,571
97 votes
3 answers
186k 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 arrow?...
Naftuli Kay's user avatar
  • 39.7k
74 votes
5 answers
40k 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 ...
Brant's user avatar
  • 845
70 votes
7 answers
207k views

How can I change my bash prompt to show my working directory?

I can print my current working dir like this myPrompt$ pwd /Users/me/myDir I want my shell to look like this /Users/me/myDir$ pwd /Users/me/myDir Is that possible? How can I do it?
bernie2436's user avatar
  • 6,655
59 votes
12 answers
41k 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 ...
xenoterracide's user avatar
56 votes
1 answer
33k views

In which situations are PS2, PS3, PS4 used as the prompt?

When I log on into the shell I see the prompt whose value is stored in PS1. I also encountered another prompt (but do not know which one) when I used the here-document syntax: bc << HERE > ...
Abdul Al Hazred's user avatar
40 votes
5 answers
28k views

tmux not colorizing PS1 prompt

I recently decided to change my PS1 variable to accommodate some pretty Solarized colors for my terminal viewing pleasure. When not in a tmux session, everything is great! Rainbows, ponies, unicorns ...
J. Sagurton's user avatar
35 votes
5 answers
82k 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 ...
neydroydrec's user avatar
  • 3,837
35 votes
7 answers
48k 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 ...
Stanislav Shabalin's user avatar
35 votes
3 answers
11k 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 ...
Ismail Badawi's user avatar
34 votes
4 answers
36k views

Shorten path in zsh prompt

Bash has the PROMPT_DIRTRIM option, e.g. when I set PROMPT_DIRTRIM=3, then a long path like: user@computer: /this/is/some/silly/path would show instead as: user@computer: .../some/silly/path Does ...
pfnuesel's user avatar
  • 5,847
33 votes
7 answers
81k 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 ...
Naftuli Kay's user avatar
  • 39.7k
32 votes
7 answers
43k views

oh-my-zsh's prompt is slow: how to fix this

I'm using macOS 10.15.2 with iTerm2, zsh 5.7.1 and oh-my-zsh (theme robbyrussell). I noticed that the prompt print is slightly slow respect to the bash one. For example, if I press enter, cursor ...
floatingpurr's user avatar
32 votes
7 answers
51k views

Show only current and parent directory in bash prompt

I'm new to bash and would like my prompt to show something that in tcsh was trivial, yet after a good google search I still cannot do. I would like my prompt to include only the current and parent ...
twalbaum's user avatar
  • 463
30 votes
4 answers
108k views

How to show the host name in Linux commandline prompt

I have several VMs and right now my command-line prompt looks like -bash-3.2$; identical on every VM, because it doesn't contain the host name. I need to always see which VM I'm on using hostname ...
uday's user avatar
  • 401
28 votes
4 answers
13k 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.
syntagma's user avatar
  • 12.3k
26 votes
5 answers
13k 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. ...
Daniel's user avatar
  • 1,207
26 votes
1 answer
50k views

How do I ask password by GUI prompt while using sudo in script?

I use Trisquel GNU/Linux with GNOME Flashback Desktop Environment. I need a GUI password prompt for user for executing command with sudo in script. Example consider following script: zenity --...
Pandya's user avatar
  • 24.6k
26 votes
3 answers
8k 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, if ...
dogbane's user avatar
  • 29.7k
26 votes
2 answers
117k 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: ...
m33lky's user avatar
  • 2,595
24 votes
6 answers
13k 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 so ...
Naftuli Kay's user avatar
  • 39.7k
24 votes
15 answers
8k views

What customizations have you done on your shell profile to increase productivity?

I know some people have some startup scripts and some people personalise the prompt. One developer uses short aliases for the long path he often visits and the frequent commands he runs. What are all ...
22 votes
3 answers
12k views

PS1='$(pwd)' why this works and why is this different from PS1=$(pwd)

Why when I enter this command the prompt changes to my directory? PS1='$(pwd)' I am using single quotes, which means no interpolation , a.k.a echo '$(pwd)' ——→ $(pwd) Furthermore, say that we ...
HashWizard's user avatar
22 votes
2 answers
37k views

Why is $ the default symbol for a user shell and # the default symbol for a root shell?

Operating a standard bash shell on a server, the PS1 prompt defaults to ending in a $ for non-root users, and # for root. IE: ubuntu@server:~$ sudo su root@server:/home/ubuntu# Why is this?
Jacklynn's user avatar
  • 375
22 votes
2 answers
5k 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 ...
xenoterracide's user avatar
21 votes
5 answers
16k 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: > &...
DisplayName's user avatar
  • 11.7k
21 votes
2 answers
86k views

How to change the prompt in Linux?

The default prompt will be root@monu dev]# Can we change the "root@monu" part and give it a desired name?
monu's user avatar
  • 1,735
20 votes
1 answer
25k views

What is percent sign prompt in a shell?

While watching a video, I saw the following: % more tinyUF.txt 10 4 3 3 8 6 5 What is this % sign before more command?
Max Koretskyi's user avatar
20 votes
2 answers
12k views

How can I make commands appear bold in zsh?

I have set up my bash shell so that any commands I type appear in bold and the commands' output is shown in normal weight: I did this by adding \e[01m at the end of my PS1 variable to turn on bold, ...
terdon's user avatar
  • 242k
18 votes
7 answers
4k views

Compact bash prompt when using a directory tree / filename

In a system with Ubuntu 14.04 and bash, I have the PS1 variable ending with the following contents: \u@\h:\w\$ so that the prompt appears as user@machinename:/home/mydirectory$ Sometimes, however, ...
BowPark's user avatar
  • 4,905
18 votes
4 answers
16k views

Showing GNU screen session name and window title in shell prompt

Is there a way to present the GNU Screen session name and window title in the prompt of the shell (let us say, the Bash prompt defined by PS1)?
brandizzi's user avatar
  • 2,884
17 votes
4 answers
2k 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 ...
Konrad Rudolph's user avatar
17 votes
1 answer
2k 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 was ...
stariz77's user avatar
  • 391
16 votes
2 answers
11k views

Meaning of \[\e]0; in PS1 in .bashrc

In .bashrc case "$TERM" in xterm*|rxvt*) PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" ;; *) ;; esac I understand ${debian_chroot:+($debian_chroot)}\u@\h: \w, but not \...
wsdzbm's user avatar
  • 2,836
16 votes
2 answers
31k 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 ...
nona's user avatar
  • 203
15 votes
5 answers
50k views

In bash how can I change the color of my command prompt? [duplicate]

Possible Duplicate: How to customize .bashrc to configure command prompt? When I run a command, I often times have trouble finding the beginning of the command output. An easy fix to this would ...
John Berryman's user avatar
14 votes
4 answers
14k views

Bash prompt execute command every time a new prompt is displayed

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 ...
danielr1996's user avatar
14 votes
1 answer
7k views

Save cursor position and restore it in terminal

I am playing with some terminal capabilities to create async prompt output on bash. I want to get something like this: while outputting string in PROMPT_COMMAND, save terminal cursor position, print ...
Lapshin Dmitry's user avatar
14 votes
2 answers
17k 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 # ...
xenoterracide's user avatar
14 votes
4 answers
2k views

tell if last command was empty in PROMPT_COMMAND

In bash, from inside PROMPT_COMMAND, is there a way to tell if the user just hit 'return' and didn't enter a command?
user's user avatar
  • 357
13 votes
5 answers
29k 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" ...
Kazark's user avatar
  • 979
13 votes
3 answers
6k 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 ...
l0b0's user avatar
  • 51.5k
12 votes
2 answers
5k 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 ...
user avatar
12 votes
5 answers
6k 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 ...
user avatar
12 votes
5 answers
5k views

PS1 prompt to show elapsed time

I currently use this to display the current time in my bash prompt: PS1=\[\e[0;32m\]\t \W>\[\e[1;37m\] 20:42:23 ~> Is it possible to display the elapsed time since the previous prompt? Such ...
TeasingDart's user avatar
12 votes
1 answer
817 views

PS1='\\ $ ' and PS1='\\\\ $ ' are the same in bash

Both PS1='\\ $ ' and PS1='\\\\ $ ' produce visually the same prompt, \ $ in both cases. Why? Is it a bug or documented behavior? Tested on bash 5.2.021 and dash 0.5.12. I have only observed it in ...
Azat Khabibulin's user avatar

1
2 3 4 5
14