Questions tagged [ps1]

DO NOT USE this tag for questions about PowerShell scripts, use [powershell] instead. Questions about the BASH shell's PS1 (Prompt String 1) input prompt facility.

DO NOT USE this tag for questions about PowerShell scripts, use [powershell] instead.

Questions about the BASH shell's PS1 (Prompt String 1) input prompt facility.

222 questions
246
votes
21 answers

(Mac) -bash: __git_ps1: command not found

I'm trying to change my command promt in terminal. I keep getting the error: -bash: __git_ps1: command not found I've tried it just by typing it into the terminal as is: __git_ps1. I've also tried it out in the .bash_profile if [ -f…
Geoff
  • 3,534
  • 5
  • 30
  • 33
91
votes
2 answers

Why doesn't my bash prompt update?

I'm new to git and I'm trying to add the current git branch to my already existing prompt, which is defined as follows…
greg0ire
  • 22,714
  • 16
  • 72
  • 101
62
votes
12 answers

How can I shortern my command line prompt's current directory?

I am using Ubuntu and I am tired of this long prompts in bash when I am working with some deep directory hierarchy. So, I would like to tweak my PS1 to shorten the working directory part the following way: Currently I…
pajton
  • 15,828
  • 8
  • 54
  • 65
40
votes
6 answers

short date in bash PS1 prompt

You can use \d in the your PS1 confuration to display a long date ie. Tues 18 May, but how can I get it to display it in a format like 18.05.2012 for example?
fergusdawson
  • 1,645
  • 3
  • 17
  • 20
27
votes
7 answers

How to expand PS1?

I have a shell script that runs the same command in several directories (fgit). For each directory, I would like it to show the current prompt + the command which will be run there. How do I get the string that corresponds to the decoded…
l0b0
  • 55,365
  • 30
  • 138
  • 223
25
votes
5 answers

Detect empty command

Consider this PS1 PS1='\n${_:+$? }$ ' Here is the result of a few commands $ [ 2 = 2 ] 0 $ [ 2 = 3 ] 1 $ 1 $ The first line shows no status as expected, and the next two lines show the correct exit code. However on line 3 only Enter was…
Zombo
  • 1
  • 62
  • 391
  • 407
22
votes
6 answers

How to print current bash prompt?

The question is simple. I want to evaluate current value of PS1 in my bash script. All materials on google point to tutorials on pimping it up, but I want to evaluate to see how would it be rendered by my current terminal, or at least by some…
Piotr Zierhoffer
  • 5,005
  • 1
  • 38
  • 59
19
votes
6 answers

Use PS0 and PS1 to display execution time of each bash command

It seems that by executing code in PS0 and PS1 variables (which are eval'ed before and after a prompt command is run, as I understand) it should be possible to record time of each running command and display it in the prompt. Something like…
Vladimir Keleshev
  • 13,753
  • 17
  • 64
  • 93
19
votes
2 answers

how to modify conda 'source activate' ps1 behavior

my current bash ps1 is as follows: bldred='\e[1;31m' # Red bldcyn='\e[1;36m' # Cyan bldwht='\e[1;37m' # White txtrst='\e[0m' # Text Reset - Useful for avoiding color bleed export…
jkarimi
  • 1,247
  • 2
  • 15
  • 27
19
votes
3 answers

PS1 command substitution fails when containing newlines on msys bash

This command succeeds $ PS1='$(date +%s) $ ' 1391380852 $ However if I add a newline it fails $ PS1='$(date +%s)\n$ ' bash: command substitution: line 1: syntax error near unexpected token `)' bash: command substitution: line 1: `date +%s)' If I…
Zombo
  • 1
  • 62
  • 391
  • 407
16
votes
1 answer

Triangular background for bash PS1 prompt

I am trying to get a triangular background for bash PS1 prompt. I have tried the existing library called powerline but it seems to be heavy for my ageing laptop. I have managed to get the background colour, but have no idea of getting the shape.…
BaRud
  • 3,055
  • 7
  • 41
  • 89
15
votes
4 answers

How to set a conditional newline in PS1?

I am trying to set PS1 so that it prints out something just right after login, but preceded with a newline later. Suppose export PS1="\h:\W \u\$ ", so first time (i.e., right after login) you get: hostname:~ username$ I’ve been trying something…
Ali
  • 1,396
  • 14
  • 37
13
votes
3 answers

Bash PS1 shows $ instead of # for root

When logging into root, the default prompt when echoed is \s-\v\$, which shows as bash-4.2#. I am trying to play around with the bash prompt so it displays the working directory. export PS1="\w \$". The prompt displays correctly, however, the symbol…
dook
  • 1,213
  • 1
  • 13
  • 30
13
votes
1 answer

Break line in terminal PS1 fix

I have this code to color my terminal: export PS1="\e[1;30m\][\e[\e[1;30m\]\e[1;33m\] \u@\H \[\e[1;32m\]\w\[\e[0m\] \e[1;30m\]]\n[\[ \e[1;31m\]\T\[\e[0m\]\e[1;30m\] ] > \e[37m\]" But I have one problem, when text should be in the new line it…
Karolis Mazukna
  • 377
  • 1
  • 6
  • 12
12
votes
3 answers

Bash prompt line wrapping issue

Newbie question, I recently changed my PS1 into this: RESET="\[\017\]" NORMAL="\[\033[0m\]" YELLOW="\[\033[0;33m\]" CYAN="\[\033[0;36m\]" export PS1="\[$RESET\]\u@\h:\[$CYAN\]\w\[$YELLOW\]\$(__git_ps1)\[$NORMAL\] \$ " But now I get a line wrapping…
hampusohlsson
  • 10,109
  • 5
  • 33
  • 50
1
2 3
14 15