prompt

How to modify w in PS1 conditionally?

How to modify w in PS1 conditionally? Everything I work on lives inside the icloud directory, making my bash prompt very long: ~/Library/Mobile Documents/com~apple~CloudDocs/Projects/foo/bar/baz @master $ My prompt is: PS1=’w[e[1;35m]$(__git_ps1 " @%s") [e[1;32m]$[e[m] ‘ Is it possible to replace only the occurence of/Library/Mobile Documents/com~apple~CloudDocs/ in w into something like icloud thus producing a better prompt like …

Total answers: 2

Change color of root user prompt

Change color of root user prompt I wanted to enable color in the shell as the root user on Ubuntu Server 22.04 after having typed sudo -s. I found this question which led me to the solution of uncommenting the force_color_prompt=yes in the file /root/.bashrc. This worked well, but I’m now wondering if there is …

Total answers: 1

custom bash prompt has leftovers from previous commands

How can I properly make a bash prompt with error colors and emoji? After solving the first issue with my custom prompt I still have another one left. When I cycle through my last used commands via the arrow-up and arrow-down keys I will sometimes have some characters from a previous command stay visible although …

Total answers: 1

changing bash output format results in strange behaviour

changing bash output format results in strange behaviour I already changed my bash output format to something like this: which I am very happy with. I achieved this by adding this code to the .bashrc: set_PS1() { local RESET=$(tput sgr0 ) local BOLD=$(tput bold ) local RED=$(tput setaf 1 ) local GREEN=$(tput setaf 2 ) …

Total answers: 1

Restoring bash prompt $PS1 to default

Restoring bash prompt $PS1 to default Is there a bash shell script or command that I can invoke to restore the original value to $PS1? I clobbered it without making a backup copy. If need be, I can always re-install bash, I’m hoping there is a less drastic method. BTW, I’m using bash v5.2.26 Asked …

Total answers: 1

FISH CLI What do the error numbers at the prompt mean?

FISH CLI What do the error numbers at the prompt mean? I am just trying out the FISH – (the FriendlyInteractiveSHell) – CLI & whenever I type in an erroneous Command, a new Prompt appears under the faulty Command prompt with a number in square brackets. I have searched through FISH’s FAQs etc., but no …

Total answers: 1

Understand PS1 environment variable

Understand PS1 environment variable On Stackoverflow, I just saw a question concerning the PS1 environment variable, which is responsible for the Linux terminal prompt. My prompt looks as follows: username@PORT-usr:/dir username is the username I use when logging into my WSL. PORT-usr is the name of my laptop. /dir is my current directory. My PS1 …

Total answers: 3

ANSI escape sequences in PS1 cause incorrect length calculation

ANSI escape sequences in PS1 cause incorrect length calculation I have a PS1 set up in my .zshrc which includes multiple ANSI escape sequences. An equivalent definition works nicely in Bash, but in Zsh (v5.8.1) it seemingly causes the shell to calculate the width of the prompt incorrectly. As a consequence, when entering longer commands, …

Total answers: 1

Is it possible to make bash stop blinking text?

Is it possible to make bash stop blinking text? I’ve been playing around with bash a bit and was wondering if it is possible to make blinking text stop if I execute another command. E.g. echo -e ’33[5mEXAMPLE33[0m’ will output a blinking EXAMPLE text; however, I’d like to know if it’s possible to make the …

Total answers: 2

oh-my-zsh prompt substitution

oh-my-zsh prompt substitution I’m modifying the intika2 theme in oh-my-zsh to add the current pyenv setting to my prompt. OMZ includes a pyenv_prompt_info command & I added it to the LEFTINFOS variable in the intika2 theme to do this. This provides the correct pyenv version whenever the .zshrc file is sourced, but not on subsequent …

Total answers: 1

Bash: control a prompt program

Bash: control a prompt program I’ve searched all over Google and the StackExchange sites, but all of the answers may work for the programs they used, but not for this (timecalc). This program is similar of fsck, having a ">>>+" prompt when opened and, apparently, not supporting receiving programmatic usage/commands unless through a Bash trick. …

Total answers: 1

How do I get a new command line to appear in terminal

How do I get a new command line to appear in terminal What is the keyboard shortcut for getting another prompt ari@ari-virutal-machine: to appear: Asked By: user3316598 || Source You appear to be running a command. The prompt will re-appear when control has been given back to the shell. This will happen when the command …

Total answers: 2

Get cursor location in tty without reading from stdin (need help with redirections)

Get cursor location in tty without reading from stdin (need help with redirections) I have written a fancy custom bash prompt, and it works really well; I just have an issue when trying to run multiple commands separated by newlines. (I apologise for the length, but I hope my issue is clear) TL;DR: getting the …

Total answers: 2

How to hide email from shell prompt with starship

How to hide email from shell prompt with starship Currently, my terminal looks like this: ~ on ☁️ email@gmail.com took 15s > I want to hide the email from the view such that the terminal view is just ~ took 15s > How do I go about doing this? Asked By: LoganN || Source In …

Total answers: 1

Display Pretty hostname in Terminal prompt?

Display Pretty hostname in Terminal prompt? My current ubuntu prompt is set as something like athos@myT460pLaptopBoughtAt2016 ~$ echo $PS1 [u@h W]$ , where h means Static hostname, as seen, it’s quite long. On the other side, I’ve set the Pretty hostname: ~$ hostnamectl Static hostname: myT460pLaptopBoughtAt2016 Pretty hostname: T460p … Is there a way to …

Total answers: 1

How to convert this bash prompt to work in zsh terminal?

How to convert this bash prompt to work in zsh terminal? I am trying to get colored text in zsh, and I like the color options given in this bash command PS1='[33[1;36m]u[33[1;31m]@[33[1;32m]h:[33[1;35m]w[33[1;31m]$[33[0m]. However, due to the syntactical differences between zsh and bash, I am unsure as to what the zsh equivalent is. Is there a …

Total answers: 1

Setting up a name in the terminal Linux

Setting up a name in the terminal Linux My question is pretty silly, but could not find nothing on the internet that explained me how. The thing is that I want to have the name displayed in the terminal as: Server mpi@raspberry: … $ but can not find how to add the "name" Server to …

Total answers: 2

How to make Bash/Zsh prompt show only the current directory and its parent?

How to make Bash/Zsh prompt show only the current directory and its parent? How can I create a bash and a zsh prompt that shows only the current directory and its parent directory? For example, if I’m at the dir ~/pictures/photos/2021, it should show: [photos/2021]$ echo hi That’s all. Would like it for bash and …

Total answers: 2

zsh prompt: check whether inside git repository and not being ignored by git

zsh prompt: check whether inside git repository and not being ignored by git In my zsh shell, I am dynamically changing prompt depending on whether I am inside git repository or not. I am using following git command to check: if $(git rev-parse –is-inside-work-tree >/dev/null 2>&1); then … now I also want to distinguish whether …

Total answers: 2

How can a shell output affect the typed text after the command prompt?

How can a shell output affect the typed text after the command prompt? I have experienced similar behaviour before, but only now I can reproduce it: Output from a command affecting the text after the next command prompt, ready to be Entered by the user. Take the following example: cat /usr/share/terminfo/a/ansi which has the following …

Total answers: 1