Questions tagged [prompt]
A string of characters displayed by interactive shells to signal the shell is waiting a user input.
616
questions
0
votes
3
answers
58
views
How to display a prompt and prevent execution against basic but dangerous commands like mv or rm
Objective
Whenever I use mv (or commands of similar nature) I want my shell to prompt me something like "Hey, you used mv. Sorry but do it again using mv -i".
I'd like to know the reasonable ...
0
votes
0
answers
8
views
Adding full path to bash print ubuntu 22.04 [duplicate]
ubuntu 22.04
bash shell
I am experimenting with the bash prompt. My objective is to display the full path as part of my command prompt (by adding the PS1 statement to my .bashrc).
From terminal, I ...
0
votes
1
answer
16
views
opening default path for root user
It may be trivial what I say, but I need to change the default opening path that OH My ZSH has. since no matter where I preposition myself in a file path (example: /home/username/Downloads/owt), when ...
2
votes
2
answers
101
views
String manipulation with backslash-escaped special character in bash prompting
I would like my bash prompt to show \etc\defaults using PS1 when I am in /etc/defaults.
I have tried these two methods
PS1="$(echo "\w" | sed 's/\//\\/g')"
PS1="$(tmp="\w&...
-1
votes
2
answers
41
views
Is it possible to output LaTeX in a shell prompt?
There are several "lambda" prompts (i.e., shell prompts which use the $\lambda$ symbol). While these look nice in theory, many fonts do not use the lambda symbol that I like: $\lambdaup$. I'...
1
vote
1
answer
27
views
Ansible: How to verify ansible_become_user, and if missing prompt for user input (multiple hosts)
I use multiple hosts and I want to prompt user to provide sudo username and password if ansible_become_user and ansible_become_password is not set in the inventory or playbook
I use following:
...
0
votes
4
answers
63
views
How to prevent child process to interfere with bash prompt?
The application in question is DaVinci Resolve. I start it from terminal. And when I close it, the message "Socket Disconnected" from the app is written to the terminal output. Then the bash ...
1
vote
1
answer
49
views
Why is the prompt shown at the top of the terminal, rather than at the bottom?
Why am I asking this?
As you can guess, it's mostly for curiosity. But why did the curiosity spring up in my mind?
Well, there's been a moment when I noticed that I was not happy that after I'd run ...
0
votes
1
answer
79
views
zsh: check whether I am currently inside my git repository (git check-ignore)
In my .zshrc, I am using following git command (from zsh prompt: check whether inside git repository and not being ignored by git) to check whether I am inside a git repository, so that I can change ...
0
votes
1
answer
23
views
How do I include the current Anaconda env in my prompt?
I found this post that perfectly describes the problem I'm having. The only difference is that I'm using zsh. When I escape the '$' as @filbranden described, it just prints the $(basename $...
0
votes
2
answers
69
views
Zsh tab completion moves command to the right by several spaces after modifying PROMPT in .zshrc
I recently wrote a function called zuperPrompt that prints out a nice looking prompt and I've set my PROMPT variable in my .zshrc to call that function like so:
setopt PROMPT_SUBST
PROMPT='$(...
1
vote
1
answer
78
views
Display branch name in $PS1 on ksh88
I want to display my current git branch in the prompt in ksh88.
I'm working on a legacy project, when the backend run on IBM's AIX, with a mandatory ksh88 shell. I can switch to say, bash, for some ...
1
vote
1
answer
55
views
Zsh: how do I remove block prefixes when writing multi-line statements in interactive mode?
When I write multi-line statements in interactive mode in Zsh, it will prefix my statements with the block type I'm in like so:
% for i in $(seq 3); do
for> echo $i
for> done
1
2
3
% function ...
1
vote
3
answers
159
views
Automatic SSH prompt input
I'm trying to copy a bunch of RSA keys to multiple servers for a specific user.
Whenever I issue the ssh-copy-id command it asks me to confirm by typing "yes", then asks me for the password.
...
0
votes
0
answers
38
views
Remove hostname from telnet login prompt / LOGIN_PLAIN_PROMPT on Ubuntu 20.04
I am trying to remove the hostname on the telnet login prompt to just display "login:" on Ubuntu 20.04.
I understood while searching around that telnet is using the program login.
I found ...
2
votes
0
answers
309
views
Equivalent of PSReadLine for bash
For my Windows Terminal using Powershell I have the plugin PSReadline which gives me some pretty handy features. For instance a navigatable list view of my history when I start typing. So if I type cd ...
4
votes
2
answers
231
views
Repeat char n times in zsh prompt
I'm working on a custom ZSH prompt and I want to repeat a char n times in a string (such as spaces for padding). This string is printed with print -rP (the -r flag ignores echo escape conventions and ...
1
vote
0
answers
39
views
Color escape codes showing up instead of colors in PS1 prompt [duplicate]
I'm trying to set up my prompt to conditionally display whether I am in a git repo, and if so, to display the branch. And I want it color coded, so I have it use some color escape sequences to make it ...
1
vote
1
answer
371
views
Displaying icons for directories in zsh prompt
This is, roughly, my left prompt for zsh:
# Libraries
autoload -Uz colors && colors
# User color
if [ "$(whoami)" = "root" ]; then
COLOR="red"
elif [ "$(...
0
votes
0
answers
207
views
Conditional zstyle format (color) for git branch name in zsh prompt (using prezto)
I am switching to zsh from bash and one thing that I'm used to is having the git branch name in my prompt coloured to reflect whether the branch is clean or not. So if my branch is main and it's clean,...
0
votes
1
answer
97
views
bash prompt doesn't re-draw properly on resizing window
Basically I have a bottom bar that always shows me the current directory on the left and on the right side the git branch. I tried to use powerline, but it only works by having a bar above the prompt, ...
2
votes
1
answer
95
views
Is it possible to use the escape codes used in shell prompts elsewhere, such as with echo?
Example:
When I run
echo -e "\[\033[;33m\][\t \u (\#th) | \w]$\[\033[0m\]"
the printed response is
\[\][ \u (\#th) | \w]$\[\]
where everything after the first \[ and before the last \] ...
1
vote
1
answer
80
views
How to get the on-screen width of the prompt produced by PS1 (with or without @P)?
Suppose, for example, that PS1 has the value shown below:
'\w (\[\e[32m\]${__git_ps1_branch_name}\[\e[0m\] \[\e[31m\]*\[\e[31m\]%\[\e[0m\]>)\$ '
...where __git_ps1_branch_name is some string, like ...
4
votes
3
answers
721
views
I can't grep tmux ls output when no tmux server is running
I'm trying to find a way to check if tmux server is running or not in order to update my zsh prompt with that information.
when tmux server is alive
> tmux ls
0: 1 windows (created Sat Jul 10 13:47:...
0
votes
1
answer
167
views
Customize zsh prompt to start at a specified directory and show all subdirectories
My current prompt looks like:
luke@Lukes-MacBook-Pro ~/Documents/abc %
which uses PROMPT='%n@%m %~ %# ' in my .zshrc file.
My .zshrc also contains cd abc since this is where I would like to start all ...
-1
votes
1
answer
109
views
Having an interactive shell experience but running everything through dash
So i'm starting to get addicted to POSIX standards and simplicity yet i hate not having autocomplete using the arrows to go through characters and i want a cool shell prompt.
so is there anyway that i ...
0
votes
1
answer
98
views
Trouble with customizing my PS1, or generally Bash prompt [duplicate]
I'm in Linux Mint 20.1 Cinnamon, not that it matters this time,
I have trouble with customizing my PS1, or generally Bash prompt to colorize the last char $ (user); # (root).
Current PS1 code in ....
1
vote
2
answers
870
views
how to modify the anaconda environment prompt in zsh?
To make my command line prompt look prettier on zsh, I added this line to .zshrc:
PROMPT='%F{green}%n%f %B%F{blue}%1~%f%b $ '
However, when I activate an anaconda virtual environment (i.e. conda ...
1
vote
1
answer
86
views
Weird output when redirecting bash prompt to a file
I redirected standard error of bash command to a file and bash prompt got redirected.
But when i print the content of file, it was empty. Where did the bash prompt go?
and again when i redirect ...
10
votes
4
answers
2k
views
Show exit code of last command in Bash prompt if it returned error
I've added the return value of the last command to PS1 (aka "the prompt") in my .bashrc.
Now I'd like to have it shown only if the value is nonzero.
Android's shell has it:
${| local e=$? (( ...
4
votes
2
answers
351
views
Where are zsh's prompt presets located?
I'd like to create my own prompt but starting from one of the presets that can be obtained from prompt -l. I'd like to know where they're defined so I can duplicate one and pimp it.
Also, it'd be nice ...
9
votes
2
answers
4k
views
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
...
1
vote
1
answer
673
views
Convert bash prompt in Terminal to zsh
I had recently updated Terminal to use zsh, after doing so the prompt on new terminal windows now displays: \[\033[1;92m\]\h:\[\033[0m\] \[\033[0;34m\][\W]\[\033[0m\] \[\033[0;31m\]\u$\[\033[0m\] ...
0
votes
1
answer
59
views
How to unbold my tcsh prompt (my tcsh prompt is stuck bold)?
Unlike most searches I did on this question, I want my prompt to not be bold. But I can't stop it.
Here is how I set my prompt.
set green = "%{\033[01;32m%}"
set white = "%{\033[...
1
vote
1
answer
360
views
agnoster theme: time in color
I'm using agnoster theme:
[![enter image description here][1]][1]
and I was wondering how to color time in a different color of username.
At the moment, my prompt_context() function from agnoster....
0
votes
1
answer
281
views
Full path in terminal prompt and title-bar with modified PS1 in .bashrc
I am on several machines running Linux Mint 20.1 "Ulyssa" - Cinnamon (64-bit), link to web, with Bash 5.0.17 as my default shell.
Today, I decided I customize my prompt and window title of ...
0
votes
1
answer
85
views
Hostname in prompt string is "localhost"
I am trying to change my prompt to my hostname (Aidan) I used
PS1=“\h \d \u]"
when I used it, it only changed to “localhost” does anyone know what I am doing wrong? I have the user created in the ...
-1
votes
1
answer
40
views
What controls line editing boundaries when editing in bash
Was reading this wonderful article on how tty works in Linux and now wondering.
When running bash each line starts with a prompt and the user cannot erase the prompt.
Is this controlled by tty at the ...
1
vote
1
answer
749
views
How to change the prezto and zsh theme prompt?
I installed yadr and prezto to style the zsh prompt.
I'm using the steeef theme:
https://github.com/sorin-ionescu/prezto/blob/master/modules/prompt/functions/prompt_steeef_setup
How do I change the ...
0
votes
1
answer
238
views
ZSH prompt disappears after typing too much
When I type for too long with zsh, the prompt disappears and it leaves a single character on the same line as the rest of what I was typing, the rest goes to a new line below it. Not sure how to tell ...
0
votes
1
answer
56
views
Reference for format of PS1 string replacement in RHEL8 [closed]
In RHEL8 the text of the command prompt presented to the user can be controlled by setting PS1. There are some format specifiers that can be used, for example using '\u' in the string will be replaced ...
0
votes
1
answer
94
views
Remove new line from batch prompt
I have the following prompt:
PS1="\[\033[s\033[0;0H\033[0;41m\033[K\033[1;33mCWD:\w | \d | \t | CM: \# | \V\s\033[0m\033[u\]
<\[\033[0;32m\]\u@\h\[\033[0m\]>\$"
Everytime I type a ...
0
votes
1
answer
58
views
Help with bash colours and long lines
When I write a long command and the line of text gets to end of terminal, it continues at beginning the same line (as if it was "overwriting it), and if I hit home it doesn't really go to the ...
0
votes
0
answers
341
views
Capturing output of sudo commands run over ssh (without password prompt)?
If I run this command, the output is what I expect, listing the directory /root on my server.
~ bash -c "ssh -t myserver 'sudo ls /root'"
Enter passphrase for key '/home/james/.ssh/ed25519':...
1
vote
1
answer
116
views
Uptime information updated in the command prompt
I want to put the uptime command information into the command prompt and have it updated every 750ms (regardless of whether I'm typing at the prompt or not).
I usually use bash but I've used zsh too, ...
9
votes
2
answers
1k
views
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/...
0
votes
0
answers
303
views
How do I get Powerline to produce the proper prompt arrows in Bash
There are several questions on this web site that are very similar to mine; however, the answers to those questions do not seem to solve my problem. To start out with let me describe my process thus ...
0
votes
1
answer
84
views
Bash: adding history -a to PROMPT_COMMAND makes incorrect calculation of last command's wall time
To calculate last command's wall time I use this code (code #1):
#
# Taken from https://stackoverflow.com/a/34812608/9881330
# Slightly modified.
#
function timer_now {
date +%s%N
}
function ...
3
votes
3
answers
198
views
Specify answer in shell script for Ubuntu
So I am trying to make a standard shellscript to install some standard software which are useful for me like net-tools, OpenSSH, Omada Controller and so on. As the standard .deb for the TP Link Omada ...
3
votes
1
answer
130
views
Return control after command ends in Ubuntu
Apologies for this newbie question but I can't find the answer anywhere.
If I run the command systemctl in a SSH terminal accessing an Ubuntu VM in Azure, then it ends with lines 159-187/187 (END), it ...