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

Anaconda environment bash prefix too long

I created an anaconda environment in a project folder specifying the path with -p option, i.e. not in the default anaconda3/envs folder: conda create -p venv The problem is that when I activate that environment, the bash prefix in the terminal is…
Dark Templar
  • 1,175
  • 13
  • 27
11
votes
6 answers

How to add an icon to the bash prompt

I know you can edit the bash prompt permanently by editing the PS1 variable in your ~/.bashrc file, mine looks like this: PS1="\[\e[0;31m\]\[\e[0;0m\]"; but can you set a tiny little image in there as well? For instance, if I wanted…
kjh
  • 3,407
  • 8
  • 42
  • 79
10
votes
2 answers

Only list host in the bash prompt if running remotely?

I'm trying to modify my Bash prompt to my will; this is how $PS1 looks at the moment (with colors edited out for clarity): PS1='\u@\h:\w\$ ' Which results in: andreas@tablet-2710p-ubuntu:~$ Can I tweak the prompt so it hides the…
IQAndreas
  • 8,060
  • 8
  • 39
  • 74
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,487
  • 3
  • 34
  • 48
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,249
  • 5
  • 25
  • 36
9
votes
1 answer

Simplifying advanced Bash prompt variable (PS1) code

So I've found the following cool Bash prompt: ..with the very basic logic of: PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi) $(if [[ ${EUID} == 0 ]]; then echo…
Det
  • 3,640
  • 5
  • 20
  • 27
9
votes
1 answer

bash: How to evaluate PS1, PS2, ...?

Possible Duplicate: Echo expanded PS1 Is there any way to 'evaluate' PS1, PS2, etc from within a bash script? Although, I can use alternate means to get all elements of my current PS1, I would really like to be able to reuse its definition…
Harry
  • 3,684
  • 6
  • 39
  • 48
8
votes
1 answer

PS1 env cannot parse on the new mac Catalina

My PS1 variable cannot parsed correctly, it looks like this, \[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\] \[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\] \[\033[01;32m\]\u@\h\[\033[01;34m\] [\w]\[\033[00m\]mv .bashrc…
Polaris
  • 366
  • 1
  • 4
  • 13
7
votes
1 answer

Changing Prompt from Shell Script?

I'm new to shell scripting and can't for the life of me figure out why this isn't working. I'm trying to change the prompt from inside my shell script. It works when I type it into the terminal, but does nothing when I run the script and choose it…
PSherman
  • 71
  • 1
  • 3
7
votes
2 answers

Bash printf %q invalid directive

I want to change my PS1 in my .bashrc file. I've found a script using printf with %q directive to escape characters : #!/bin/bash STR=$(printf "%q" "PS1=\u@\h:\w\$ ") sed -i '/PS1/c\'"$STR" ~/.bashrc The problem is that I get this error…
il0venoobs
  • 147
  • 1
  • 3
  • 8
7
votes
2 answers

How can I make my terminal prompt extend the width of the terminal?

I noticed in this video, that the terminal prompt extends the entire width of the terminal before breaking down to a new line. How can I set my PS1 variable to fill the remaining terminal space with some character, like the way this user did? The…
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
6
votes
1 answer

Script calls other script as .ps1 but not as a .exe using ps2exe

$password = ConvertTo-SecureString “Password+++” -AsPlainText -Force $Cred = New-Object System.Management.Automation.PSCredential ("Admin", $password) $FileLocale = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition Write-Output…
6
votes
4 answers

echo $PS1 in script

Silly question, but since I'm such a newbie at Linux OS, I'm having trouble to make this simple script to echo the result of PS1. If I type echo $PS1 in bash, it shows me the result, but not in the script. It returns…
Rafael
  • 113
  • 2
  • 7
6
votes
2 answers

Dynamic change bash prompt according to path

I would like to know if it is possible to change the PS1 according to the current path or pwd value? For example: cd /home/user/directory1 PS1=[\e[1;32m\u\e[m@\e[1;34m\h\e[m \e[1;33m\W\e[m] But if i'm in an another directory : cd…
Vender Aeloth
  • 690
  • 1
  • 12
  • 27
6
votes
2 answers

zsh agnoster theme chagne prompt/ps1

How can I change the prompt of my zsh shell while still retaining the cool coloring that agnoster provides? For people who don't know, it looks like this I want to add some things like ! and \u before the working directories. I've tried the usual…
user1529956
  • 735
  • 2
  • 10
  • 24
1
2
3
14 15