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
1
vote
3 answers

PS1 can't have two "\$"?

I want my bash Prompt String 1 to have both the date/time and the return code of the last command. So, I thought I could just do PS1="\[\e[00;34;01m\]\$(date +'%a %b %e, %T')\[\e[35m\] \$?\[\e[00m\] >> " Which I thought would give me a blue date…
dylnmc
  • 3,810
  • 4
  • 26
  • 42
1
vote
1 answer

bash color settings messing something up

blue="\033[38;5;32m\]\033[48;5;256m\]" purple="\033[38;5;198m\]" green="\[\033[0;32m\]" reset="\[\033[0m\]" export PS1="$purple\u$green\$(__git_ps1)$blue \W $ $reset" If the colors were set using the simpler format, as for green, everything would…
David Rosson
  • 1,054
  • 1
  • 10
  • 15
1
vote
1 answer

Bash $PS1 Trouble (ubuntu)

So I have a script in my .bashrc for customizing my prompt (see below). function git_unpushed { brinfo=$(git branch -v) if [[ $brinfo =~ ("[ahead "([[:digit:]]*)]) ]] then echo "Not Pushed: ${BASH_REMATCH[2]}" fi } function…
Nicholas Summers
  • 4,444
  • 4
  • 19
  • 35
1
vote
1 answer

bash: displaying absolute path with symlinks resolved in prompt

Is it possible to have my shell display the full current working directory, even when I cd into a symlink? My current PS1 reads PS1=" [ \w ] => " However when I cd into a linked directory, it displays (for example) [ ~/LINKEDDIR ] instead of…
ianking
  • 75
  • 6
1
vote
1 answer

How to set a variable from the bash $PS1

The bash PS1 variable seemingly has access to all the shell's variables. $ foo=bar $ PS1='$foo ' bar # Works as expected. But, setting a variable there does not work. $ PS1='$(bar=baz)\$ ' $ echo $bar $ # Does not work. Why, and how to make this…
Camilo Martin
  • 37,236
  • 20
  • 111
  • 154
1
vote
2 answers

How to omit user@location from Unix shell prompt?

I am using Unix and I login in my account. Then my command line looks like this: [username@somestupidfolder]$ How can I hide this information so I can get clean $ as cursor. Basically: [username@somestupidfolder]$ to $
Ing. Michal Hudak
  • 5,338
  • 11
  • 60
  • 91
1
vote
1 answer

How to color path levels using bashrc?

In my ~/.bashrc I have export PS1="\[\033[0;39m\]\u@\h:\[\033[0;32m\]\w\$\[\033[00m\] " which changes the current working directory's path color into a green color. Is it possible to color each path level with a different color using bashrc? For…
Rlearner
  • 351
  • 1
  • 4
  • 13
1
vote
1 answer

Setting ${PWD} in PS1 variable does not work in Korn Shell

I have set the below as my PS1 variable in Solaris 5.10 PS1="\[${USER}@`uname -n` ${PWD}]\$ " When I start my terminal session, it shows the correct directory(i.e my home directory) but when I change to some other directory it actually does not…
Optimus Prime
  • 36
  • 1
  • 5
1
vote
1 answer

PS1 correct line wrapping in Bash

I want to execute a command that writes some dynamic info to my shell prompt. It works fine if I do the coloring statically, because I can just put \[ and \] before and after the escape sentence: '\[\e[0;91m\]$(printSomething)\[\e[0m\]' But if the…
petersohn
  • 11,292
  • 13
  • 61
  • 98
1
vote
0 answers

Git PS1 dirtstate shows an undocumented "#" symbol

I'm on a Mac, I've installed git via brew and sourced the git-completion.bash script file. I've exported the GIT_PS1_SHOWDIRTYSTATE=1 variable to also show the status of the current branch. Finally I've included the $(__git_ps1 '(%s)') in my…
Leonardo
  • 4,046
  • 5
  • 44
  • 85
1
vote
0 answers

__git_ps1 breaks bash's vi mode

I'm running ubuntu 13.04 and I have a PS1 like this PS1="\$(__git_ps1 '(%s) ')\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ " And I'm used to use the vi mode of bash with set…
flx
  • 14,146
  • 11
  • 55
  • 70
1
vote
2 answers

bash resolving variables in literal value for PS1

Attention : do not offer more simple solution for that example case, it is generated only to show a problem, order is taken from real problem. I try to change my PS1 in ".bashrc", do not want to print here whole code(but do need storing template in…
Roman Ivanov
  • 2,477
  • 3
  • 20
  • 31
1
vote
1 answer

Understanding weird character syntax in PS1 bash prompt

Here is my bash prompt: Here is the PS1 that generates that PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]`__git_ps1` \$ ' Now, here is the stuff I understand: $debian_chroot - used for…
CuriousMind
  • 33,537
  • 28
  • 98
  • 137
1
vote
3 answers

Stop bash from escaping a string inside a string

I've been messing around with .bashrc, trying to get a new colored PS1 that could tell me automagically if I'm using a Python virtualenv. I'm very, very new to Bash, so after some research I created something like this (simplified for…
Gabe
  • 1,270
  • 12
  • 39
1
vote
1 answer

Scroll problems with empty PS1

If I scroll up through the history and come across a long line that wraps, then scroll back down, the lines will be scrambled. I have read around that this can be caused by incorrectly escaping color codes, but this happens even with an empty PS1,…
Zombo
  • 1
  • 62
  • 391
  • 407