Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
For me prompt means value of PS1, so guys just post this
Code:
$ echo $PS1
I never did this myself but think PS1 should different depending on working on /dev/pts/x or /dev/tty. On virtual terminal one use something more nice or in contrary very simply like % I use now. While on tty only % is far too cryptic.
Edit: PS1 is primary prompt. Myself never touched default PS2 and so on, but maybe someone has for some reasons customized also non-primary prompts. If I would be really interesting in reasons.
You do need current working directory. It's not just bling. When I was setting up my new Slackware-15, I chrooted across and just happened to be working in the /etc/rc.d directory when I forgot where I was and accidentally deleted all my startup scripts. Not a disaster at that stage, but certainly a nuisance. That was because I had not set up a proper root prompt on the new system and the default prompt just said bash# without any indication of where you were. Believe me, I corrected that before I went any further.
Some folks will certainly find that useful. I really dislike it when you're getting deep in the filesystem hierarchy and your prompt is taking up over half the screen width. So, I prefer to just type pwd whenever I get lost, or if I just want to confirm I'm where I think I am. Yep, I'm probably just weird, but it works for me.
Myself never touched default PS2 and so on, but maybe someone has for some reasons customized also non-primary prompts. If I would be really interesting in reasons.
I do it in bash scripts sometimes, so it only lasts for the script, never in ~/.bashrc
Code:
#!/usr/bin/bash
col=$(tput setaf 2)
clr=$(tput sgr0)
options="q a b c"
PS3=""$col"Select an option.: "$clr""
select opt in $options; do
case $opt in
q) clear; exit ;;
a) echo "a" ;;
b) echo "b" ;;
c) echo "c" ;;
esac
done
Is there someone with 2-line or more prompt? I was hesitating about terminal and shell which allow to provide such cool looking prompts. 2-line prompt can be convienient to work with long paths. Say username, hostname, date/time, working directory are on top line while bottom line is for input.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.