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
6
votes
1 answer

How do I set $? in functions called by PS1?

I currently have a prompt in bash that calls a function to output the return code of the last command run (if non-zero): exit_code_prompt() { local exit_code=$? if [ $exit_code -ne 0 ] then tput setaf 1 printf "%s"…
Stephen Wattam
  • 525
  • 2
  • 12
5
votes
1 answer

How to set PS1 that make both git and conda can show in the bash?

My .bashrc: # show a short way shortwd() { num_dirs=3 pwd_symbol="..." newPWD="${PWD/#$HOME/~}" if [ $(echo -n $newPWD | awk -F '/' '{print NF}') -gt $num_dirs ]; then newPWD=$(echo -n $newPWD | awk -F '/' '{print $1 "/.../"…
5
votes
2 answers

Where does bash prompt escape sequence \h get the hostname from?

\h is a bash prompt escape sequence that expands to the hostname. Where does it get the hostname from? On my system it shows a value that I cannot find anywhere, not in hostname -f or /etc/hosts or /etc/hostname or /etc/sysconfig/network or…
Michael Martinez
  • 2,693
  • 1
  • 16
  • 19
5
votes
1 answer

Dynamic elements in bash PS1

I have put the following in my ~/.localsh file to customize my bash prompt when working with git. Basically I want to get the current branch displayed in my terminal. The gitk tool shows branches with green background and black foreground, so thats…
eric.frederich
  • 1,598
  • 4
  • 17
  • 30
5
votes
2 answers

PS1 bash command substitution not working on windows 10

This is my script that sets up my bash PS1 # Reset Color_Off="\[\033[0m\]" # Text Reset # Regular Colors Black="\[\033[0;30m\]" # Black Red="\[\033[0;31m\]" # Red Green="\[\033[0;32m\]" # Green Yellow="\[\033[0;33m\]" …
StefanoGermani
  • 721
  • 7
  • 18
5
votes
1 answer

Getting a dynamic bash prompt PS1 right

I'm working on a dynamic bash prompt where I want reported in PS1 which version of a config file is enabled on the local filesystem. This is a contrived example of what I'm trying to do, simplified. The things that are going wrong: bad wrapping…
groknaut
  • 53
  • 1
  • 5
5
votes
1 answer

$MSYSTEM variable in bashrc

NOTE I am using Windows 7. On installing msysgit and GitHub for Windows, I found that git bash can be called from the folders. I opened up the terminal and first thing I wanted was to change how it displays in the console. Here is what echo $PS1…
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
5
votes
1 answer

Bash PS1 window title?

Say I have this as my PS1 PS1='\[\e]0;TITLE\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ ' it will give me this prompt Steven@Steven-PC ~ $ with a window title as TITLE I understand that this part \e]0;TITLE\a creates the title, but I don't…
Zombo
  • 1
  • 62
  • 391
  • 407
4
votes
3 answers

Changing PS1 prompt in a Bash parent shell

Using a script, I was to change the prompt of the parent Bash shell. I have tried the following: PS1="Hello World > " This changes the prompt of the subshell, which the script is running in, but which command would I use to change the prompt of the…
batsta13
  • 549
  • 2
  • 12
  • 26
4
votes
1 answer

How to modify conda prompt string content

How can I edit the conda prompt's behavior without touching my normal prompt? I want to retain conda's prepend-to-PS1 behavior, but change the string that gets prepended. The question how to modify conda 'source activate' ps1 behavior is very…
drmuelr
  • 955
  • 1
  • 13
  • 30
4
votes
5 answers

How to display conda's environment in zsh (not using oh-my-zsh)?

I use zsh but not equipted with oh-my-zsh, since I cloned many git repos on my machine and oh-my-zsh's default theme or 'josh' theme makes it very slow, for cd and ls commands, etc. Thus I delete oh-my-zsh and only use zsh's default recommended…
ChrisZZ
  • 1,521
  • 2
  • 17
  • 24
4
votes
2 answers

How can I properly use two-character-width emoji in my bash prompt?

I want to use an American flag emoji in my bash prompt (i.e. PS1 environment variable). However, the American flag emoji causes the terminal cursor to offset an extra character to the right. is comprised of two unicode characters, and . I believe…
Andrew Kirna
  • 1,346
  • 16
  • 18
4
votes
3 answers

Setting a variable within a bash PS1

I'm trying to customize my bash prompt and I'm having trouble with a few conditionals. My current PS1 looks like this. export PS1="\ $PS1USERCOLOR\u\ $COLOR_WHITE@\ $COLOR_GREEN\h\ $COLOR_WHITE:\ $COLOR_YELLOW\W\ \`if type parse_git_branch >…
Jacob Tomlinson
  • 3,341
  • 2
  • 31
  • 62
4
votes
2 answers

Characters in PS1 variable

My PS1 variable : \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ I understand everything except the first part \[\e]0;\u@\h: \w\a\]. What is the purpose of this part? It doesn't seem to affect my prompt. In fact my question could…
Gradient
  • 2,253
  • 6
  • 25
  • 36
4
votes
1 answer

Get actual prompt length

I wanted to print something like this on my gnome-terminal [abc@host pwd]$ ************************************************************ using some manipulations in PS1 but the number of stars are dynamic depending on PS1 and terminal width. So…
Kaunteya
  • 3,107
  • 1
  • 35
  • 66
1 2
3
14 15