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
4
votes
0 answers

Bash prompt variable - \W intrepretation

I'm trying to fix a curious problem I'm having with bash prompt (PS1) manipulation, and I'm very confused as to why \W is re-writing 'pwd' improperly in my case. user@server-01:/repo$ PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$…
3
votes
1 answer

How to remove array symbol at the start of terminal Mac OS X

I'm new to Mac and I changed the PS1 environment variable to make it look like Ubuntu. I don't know if I screwed something up or if this is a natural Mac thing, but whenever I do a command, there's an array symbol that goes at the front of the…
3
votes
1 answer

Bash or Z shell terminal prompt with time and date

I am running Bash and Z shell (zsh executable) as my terminal environments. My main goal is that I would like to add a timestamp onto all of my prompts... Something along the lines of: PS1_DATE="\D{%Y-%m-%d %H:%M:%S}" This is the prompt from…
Purry
  • 131
  • 2
  • 5
3
votes
3 answers

Replacement of PS1 variable in .bashrc using Sed or Perl

I am trying to replace a line in file and am running in to issues. Original File: export PS1='\h:\w\$ ' Command I am running: perl -pi -e 's~PS1.*~PS1="\n\[\e[32;1m\][\[\e[37;1m\]\u@\h:\[\e[37;1m\]\w\[\e[32;1m\]]\\$ \[\e[0m\]~g' ~/.bashrc Error…
brakertech
  • 1,467
  • 1
  • 13
  • 20
3
votes
2 answers

Show pipenv virtualenv in PS1

Pipenv is a relatively new packaging tool that encompasses "Pipfile, Pip, and Virtualenv". I have made changes to simplify my PS1 in .bashrc but now find that I need my PS1 to tell me when I am using my virtualenv. Current PS1: PS1='\w $ ' From the…
Max
  • 2,072
  • 5
  • 26
  • 42
3
votes
1 answer

How to make a function work in background in bash / replace text / CPU usage

I have been playing around with the bashrc and one of the thing I want to see at all time is my cpu usage in percentage. I decided to set this data in my PS1. The problem is that to have an accurate estimation of my CPU usage I need to do operations…
PiggyGenius
  • 443
  • 2
  • 9
  • 25
3
votes
4 answers

Conditional space in PS1

I'm basically trying to create a PS1 that has this output: $ ~/Projects/Blah (master): However, if the folder I'm in is not a Git repository, I want it to look like this instead: $ ~/Projects/Blah: This is my current PS1: export PS1="$ \w…
Saad
  • 49,729
  • 21
  • 73
  • 112
3
votes
1 answer

Is running git update-index --refresh from PS1 prompt safe?

I've been researching the fastest way to check for changes in a repo to update the PS1 prompt. For reasons not worth elaborating, no access to the __git_ps1() macro, and anyway other posts have suggested various commands, including those used in…
Steve J
  • 31
  • 2
3
votes
1 answer

bash prompt shell displayed differently in terminal and tty console

This is a portion of my ~/.bashrc: prompt(){ local EXIT="$?" # return code PS1="" local red="\[\033[0;31m\]" # text colour local purple="\[\033[0;35m\]" # text colour local normal="\[\033[0m\]" # text colour if [ $EXIT…
tukusejssirs
  • 564
  • 1
  • 7
  • 29
3
votes
2 answers

How to empty the value of $? variable in .bashrc?

I've been trying to customize my bash prompt so that it'll look like ┌─[error_code_if_not_zero]─[time_short]─[username]─[current_folder]─[git_branch] └─▪ And here is my .bashrc: # command completion source…
Chan Kha Vu
  • 9,834
  • 6
  • 32
  • 64
3
votes
1 answer

Use PS1 setting to set different terminal background color over ssh

I want to use the PS1 setting in my .bashrc file to change the color of the terminal based on whether I'm on my local machine or using ssh. My current .bashrc file on both my local machine and the ssh server is (the…
Misconstruction
  • 1,839
  • 4
  • 17
  • 23
3
votes
2 answers

bashrc not exporting variable in function when changing directories

I have several projects I work on. Instead of setting aliases for each project's location, I would rather set it when I navigate to that specific directory. Each project is a git repo and I already have a mechanism that appends the current branch…
eggmatters
  • 1,130
  • 12
  • 28
3
votes
0 answers

What's the point of \[ and \] in the PS1 prompt?

According to man bash, in the PS1 environment variable (defining the shell prompt): \[ begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt \] end a sequence of non-printing…
IpsRich
  • 797
  • 10
  • 23
3
votes
2 answers

How can this PS1 variable be defined in single-quotes?

The default .bashrc file for Debian-based systems sets $PS1 like this: PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' What confuses me is that ${debian_chroot} part. According to StackOverflow: Difference between single and double quotes in…
IQAndreas
  • 8,060
  • 8
  • 39
  • 74
3
votes
1 answer

PS1 variable in single and double quotes - bashrc

I've set my bashrc file as follows (for Git Bash) source ~/git-prompt.sh source ~/git-completion.bash export…
hjpotter92
  • 78,589
  • 36
  • 144
  • 183