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

PS1: How do I echo colorcodes from functions that get executed in subshells?

I've never really touched bash before so it might be that the solution to my problem is obvious, but I can't wrap my head around it. I want to set my PS1 to certain values with certain colors. It works fine until I echo a color code from a subshell,…
melodyscat
  • 11
  • 2
1
vote
1 answer

how to change PS1 based on what directory i`m working in?

I get errors -bash: test1.bash: line 5: syntax error near unexpected token `elif' 'bash: test1.bash: line 5: `elif [$PWD | grep /mnt/c/ !="" OR pwd | grep /mnt/d/ !=""] then i have tried nothing other than the code i written if [$PWD | grep…
bob
  • 537
  • 1
  • 5
  • 12
1
vote
1 answer

Fixing historical command-line corruption from PS1 escape sequence

I (believe) I am having an issue with the following PS1 not properly having an escape sequence: \x1b[35mabc\x1b[0m \x1b[33mxyz\x1b[0m \x1b[34m\w\x1b[0m\$ The prompt looks okay until I begin to use historical command-lines and then bash seems to lose…
Brian Bruggeman
  • 5,008
  • 2
  • 36
  • 55
1
vote
0 answers

nextline spacing PS1

So here is my current PS1 PS1="\u[\W]\$(__git_ps1) \t \$? \\$ \[$(tput sgr0)\]" Whenever the PS1 overflows onto the next line I get this weird spacing display whenever I type something. Whats even weirder is that I can't delete the typed words and…
isignisign
  • 541
  • 2
  • 4
  • 13
1
vote
1 answer

bash scrolling after bottom of terminal copies background color to the entire line below. (eg. prompt with background color)

calculate_prompt1() { host="my-linux" git_branch="a very very very very very very very very very very very very very very long prompt" prompt="@$host \\w : \[$(tput bold)$(tput setab 1)$(tput setaf 7)\]${git_branch}\[$(tput sgr0)\]\$ " …
abdullam
  • 225
  • 1
  • 3
  • 15
1
vote
2 answers

bash prompt : how to display only the filename with PS1?

I am currently displaying the directory path and the git branch using PS1: parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $…
user762579
1
vote
1 answer

PS1 only outputs the PS1 string not proper values

I'm using iTerm2 on MacOS Sierra. I try to edit the PS1 in variable .bash_profile to be PS1="\h:\W \u \$" but in terminal I get the promp \h:\W \u \$ instead of Simon:~ simon $ Any ideas why it behaves like this?
deFunc
  • 33
  • 4
1
vote
1 answer

git bash on windows (mingw64) editing .bash_profile ps1

I am following the Udacity course where in Lesson 1 video 29. they talk about customizing the git bash and setting up workspace. I did dig into how the .bash_profile should be edited and it almost works as I want it. Except I can't figure out how to…
Bar6
  • 31
  • 5
1
vote
2 answers

Mac export PS1 doesn't handle escaped commands

I'm just trying to change the terminal prompt in macOS Sierra. Nothing fancy, I just need to know the current path. In my ~/.bash_profile I'm adding export PS1="[\w] > " I know that \w should be replaced by current full path but none of the escape…
rmvz3
  • 1,133
  • 2
  • 16
  • 27
1
vote
1 answer

How can I pipe a prompt string (PS1) into a command and have the text result be PS1?

What I currently have in my .bash_profile is export PS1="\w ↪ Bob♔ Home > " What I wish to do is something like export PS1="\w ↪ Bob♔ Home > " | lolcat where the normal string used for the prompt is piped into the lolcat command, and the result of…
Gigi Bayte 2
  • 838
  • 1
  • 8
  • 20
1
vote
1 answer

Bash: How to set changing variable in PS1, updating every prompt

I've searched for quite a while, but haven't been able to find a post or any information whatsoever about adding a variable that is, well, variable (i.e. changing) within PS1 in bash, that will update every time a new prompt occurs. In concreto, I…
7z.
  • 85
  • 1
  • 6
1
vote
3 answers

How to set a empty line before output in bash shell?

I have this: $ any_command any_command: command not found But i need this: $ any_command any_command: command not found What add to PS1?
1
vote
1 answer

How to display git branch in PS1 with other output?

I got to display just the branch name in the PS1 if I am in a git repo linux PS1 - display branch name only inside a git repo, but I am not able to get it integrated with my earlier PS1, which is PS1="[\D{%F} \@] \u /\W $ " this displays, datetime…
mtk
  • 13,221
  • 16
  • 72
  • 112
1
vote
1 answer

linux PS1 - display branch name only inside a git repo

After searching the net, I found that one can display the git branch name with the PS1 with below PS1="$(__git_ps1 ) " While this is working fine, and it display the branch name in PS1 prompt. But it is displayed where-ever I navigate, even…
mtk
  • 13,221
  • 16
  • 72
  • 112
1
vote
0 answers

Set git bash_profile PS1 to color branch name when commits have not been pushed or pulled yet

I'm using this .bash_profile file to know my git status in the command line: source /usr/local/git/contrib/completion/git-prompt.sh source…
Rotem
  • 2,306
  • 3
  • 26
  • 44