Questions tagged [ps1]

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

285 questions
234
votes
19 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,408
  • 4
  • 26
  • 32
86
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
  • 21,120
  • 15
  • 68
  • 95
55
votes
11 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
  • 14,670
  • 6
  • 50
  • 63
34
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,445
  • 3
  • 14
  • 18
23
votes
6 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
  • 48,420
  • 21
  • 118
  • 185
23
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…
Steven Penny
  • 82,115
  • 47
  • 308
  • 348
17
votes
2 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…
Steven Penny
  • 82,115
  • 47
  • 308
  • 348
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
  • 2,609
  • 2
  • 31
  • 70
16
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,034
  • 1
  • 35
  • 56
15
votes
3 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,339
  • 14
  • 36
11
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,027
  • 1
  • 11
  • 25
11
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…
ThiSGUy
  • 309
  • 1
  • 4
  • 12
10
votes
1 answer

bash __git_ps1 command not found

I am a beginner trying to setup a developer environment on my new Mac following the steps from this link: http://vanderveer.be/setting-up-my-perfect-developer-environment-on-osx-10-8-mountain-lion-10-8-2-final-edition/. After executing the files…
alchuang
  • 3,087
  • 2
  • 29
  • 47
10
votes
2 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
  • 9,346
  • 5
  • 30
  • 46
10
votes
4 answers

PS1 env variable does not work on mac

I have a script(not written by myself) which shows the git branch/svn branch in my command prompt. Does anyone know why this would not work on mac? It works perfectly in linux. From https://github.com/xumingming/dotfiles/blob/master/.ps1: # Display…
James.Xu
  • 8,023
  • 5
  • 23
  • 35
1
2 3
18 19