View previous topic :: View next topic |
Author |
Message |
Techie2000 Guru
Joined: 16 May 2002 Posts: 344
|
Posted: Sat Jun 01, 2002 12:23 am Post subject: Changing the default .bash_config |
|
|
where is the default .bash_config so I can go and make it say:
root@linux:/>
instead of
linux /# |
|
Back to top |
|
|
tyreth Apprentice
Joined: 27 May 2002 Posts: 238 Location: Melbourne, Australia
|
Posted: Sat Jun 01, 2002 4:52 am Post subject: |
|
|
That's just the PS1 environment variable. Throw it in /etc/profile or /etc/bashrc I think. If you want it just for one user then I think it's ~/.bashrc
Hope that helps. I think there's a bash howto on www.linuxdocs.org |
|
Back to top |
|
|
grakker Tux's lil' helper
Joined: 17 Apr 2002 Posts: 100
|
|
Back to top |
|
|
wont-i n00b
Joined: 06 Jun 2002 Posts: 8
|
Posted: Sun Jun 23, 2002 5:16 am Post subject: Extra informative Bash prompt |
|
|
I've got a bash prompt that I've been using for quite awhile now, and that others that I've shown it to often want to make use of, so I thought I'd offer it up here, too.
It's a 3 line prompt, but I find it provides me almost every bit of info about my current environment I need or want at a glance.
Note: The following assumes a black terminal background. If you're using a white background, you'll need to adjust the color codes to be more visible (as can be seen in the example prompt shown below).
Code: | PS1="\n\[\033[35m\]\$(/bin/date)\n\[\033[32m\]\w\n\[\033[1;31m\]\u@\h: \[\033[1;34m\]\$(/usr/bin/tty | /bin/sed -e 's:/dev/::'): \[\033[1;36m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files \[\033[1;33m\]\$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\033[0m\] -> \[\033[0m\]" |
This ends up producing a prompt such as the following:
Code: |
Sun Jun 23 00:33:58 EDT 2002
/usr/src/linux
wont@calvin: pts/3: 23 files 3.8Mb -> |
where:
Line 1-- current date and time
Line 2-- current working directory
Line 3-- username @ host: console number: # of files in directory total size of directory on disk ->
Hope this is of interest to someone out there.
Will |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Sun Jun 23, 2002 6:12 am Post subject: |
|
|
I've not botherd to relearn prompt code. I don't need all that info, but this certainly makes
it easier to learn
Thanks for the tip.
EDIT:
Some other bash prompt threads: _________________ Quis separabit? Quo animo?
Last edited by pjp on Sat Dec 25, 2004 3:33 am; edited 1 time in total |
|
Back to top |
|
|
andee n00b
Joined: 04 Jun 2002 Posts: 41
|
Posted: Sun Jun 23, 2002 6:50 am Post subject: Re: Extra informative Bash prompt |
|
|
thanks
My prompt looks really pretty right now |
|
Back to top |
|
|
JefP@@ Apprentice
Joined: 09 May 2002 Posts: 179 Location: Belgium
|
Posted: Sun Jun 23, 2002 9:58 am Post subject: |
|
|
it sure is interesting ... I'll try it out once, when I've got the time |
|
Back to top |
|
|
bert n00b
Joined: 20 Jun 2002 Posts: 11 Location: Amsterdam
|
Posted: Sun Jun 23, 2002 11:08 am Post subject: |
|
|
Here's a bash prompt that shows battery status on a laptop. Needs apm tools / kernel support available (and awk).
Code: | PS1="\`apm|awk '\$5~/%/{print \$5}\$6~/%/{print \$6}'\` [\\u@\\h:\\w] \\$ " |
.. and this is what it looks like
Quote: | 100% [bert@brahms:~/movies] $
99% [bert@brahms:~/movies] $ |
|
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Sun Jun 23, 2002 5:01 pm Post subject: |
|
|
Hope you don't mind, I edited your prompt to produce mine. I removed the time, # of files
and dir size. Changed the look a tiny bit, will probably change colors in the future.
Code: | PS1='\n\[\033[32m\]\w\n\[\033[0m\][\[\033[1;31m\]\u@\h \[\033[1;34m\]$(/usr/bin/tty | /bin/sed -e '\''s:/dev/::'\'')\[\033[0m\]] \[\033[0m\]' |
/usr/portage
[user@hostname pty/s0]
Again, meant for a dark background. 1st line is current directory path. 2nd line is user
and hostname with terminal enclosed in [ ] (Hard to see here, they are white). _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
bone Apprentice
Joined: 07 Jun 2002 Posts: 255 Location: Midwest, USA
|
Posted: Wed Jun 26, 2002 12:01 pm Post subject: |
|
|
About 5 years ago. I borrowed the sets from a bashcolor script and did something similar.
[This is from my /etc/profile file]
# Color Variables for Prompt
GRAD1='\333\262\261\260'
GRAD2='\260\261\262\333'
YLOBRN='\[\033[01;33;43m\]'
WHTBRN='\[\033[01;37;43m\]'
REDBRN='\[\033[00;31;43m\]'
REDBLK='\[\033[00;31;40m\]'
PPLBLK='\[\033[01;35;40m\]'
WHTBLK='\[\033[01;37;40m\]'
NONE='\[\033[00m\]'
HBLK='\[\033[00;30;30m\]'
HBLU='\[\033[01;34;34m\]'
BLU='\[\033[00;34;34m\]'
YEL='\[\033[00;33;33m\]'
WHT='\[\033[01;37;37m\]'
PRPL='\[\033[00;34;35m\]'
RED='\[\033[01;31;31m\]'
NORM='\[\033[01;00;0m\]'
export GRAD1 GRAD2 YLOBRN WHTBRN REDBRN REDBLK PPLBLK WHTBLK NONE HBLK HBLU BLU YEL WHT PRPL RED NORM
# Prompt Settings
if [ `/usr/bin/whoami` = 'root' ]
then
if [ "$SHELL" = '/bin/bash' ] || [ "$SHELL" = '/bin/sh' ]
then
PS1='\n'$WHT'*'$NONE'['$HBLU'\u'$WHT'@'$HBLU'\h'$WHT':'$HBLU'\W'$NONE']'$NONE' '
PS2='\n'$WHT'*'$NONE'['$HBLU'\u'$WHT'@'$HBLU'\h'$WHT':'$HBLU'\W (2)'$NONE']'$NONE' '
fi
else
if [ "$SHELL" = '/bin/bash' ] || [ "$SHELL" = '/bin/sh' ]
then
PS1='\n'$NONE'['$HBLU'\u'$WHT'@'$HBLU'\h'$WHT':'$HBLU'\W'$NONE']'$NONE' '
PS2='\n'$NONE'['$HBLU'\u'$WHT'@'$HBLU'\h'$WHT':'$HBLU'\(2)'$NONE']'$NONE' '
fi
fi
================
[user@host:directory]
What this does is make a very nicely colored prompt that looks well at home with both white and black backgrounds (but probably looks better with black background). And the added feature of when your root, it sets your prompt with a star in front of it like this.
*[root@host:directory]
I am in a habit of having so many sessions running, that I tend to forget which one is root or not, and just grab the session and start working. its very bad to test untested or foreign code as user root, so this helps me to make sure i do not trash a system by running bad/rogue code. |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Wed Jun 26, 2002 5:09 pm Post subject: |
|
|
It is also very bad to intend to reboot a remote client and forget that you are in the
server terminal. Fortunately it was during a setup phase _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
TGL Bodhisattva
Joined: 02 Jun 2002 Posts: 1978 Location: Rennes, France
|
Posted: Wed Jun 26, 2002 10:26 pm Post subject: |
|
|
There exists a program called "bashish" which allows you to switch between a lot of prompts (from the best to the ugliest ones):
http://bashish.sourceforge.net/
There is no ebuild as far as I know, maybe I'll write one someday...
-- T. |
|
Back to top |
|
|
HammeR n00b
Joined: 09 Jun 2002 Posts: 17
|
Posted: Sun Jun 30, 2002 4:59 pm Post subject: |
|
|
Sorry for being such a n00b, but where do I put this? In ~/.bashrc ?
EDIT: Did some research and found out that this should be in /etc/profiles .. _________________ "Linux is communism" - Balmer, Microsoft. |
|
Back to top |
|
|
Spark Tux's lil' helper
Joined: 30 Jun 2002 Posts: 87
|
Posted: Wed Jul 03, 2002 6:02 pm Post subject: |
|
|
Thx. This is my one now:
PS1='\[\033[0m\][\[\033[1;36m\]\w\[\033[0m\]] \[\033[0m\]'
Looks like this:
[/usr/src/linux]
(only good for black background of course)
and that's everything I need =) simplicity rules. |
|
Back to top |
|
|
Spark Tux's lil' helper
Joined: 30 Jun 2002 Posts: 87
|
Posted: Thu Jul 04, 2002 7:24 pm Post subject: |
|
|
Hmm, I put this in /etc/profile but it only works on tty, not in xterm. Can anyone tell me what I have to do to get it working in X? |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Thu Jul 04, 2002 10:28 pm Post subject: |
|
|
Try putting it in your ~/.bashrc file _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
tfoss n00b
Joined: 04 Jul 2002 Posts: 8
|
Posted: Thu Jul 04, 2002 10:31 pm Post subject: Try .bashrc |
|
|
Spark wrote: | Hmm, I put this in /etc/profile but it only works on tty, not in xterm. Can anyone tell me what I have to do to get it working in X? |
Try putting it in your ~/.bashrc.
(If i recall, /etc/profile is read only if its a login shell, not an interactive shell (which xterm things are)... ~/.bashrc is read for both...)
-Ted |
|
Back to top |
|
|
Spark Tux's lil' helper
Joined: 30 Jun 2002 Posts: 87
|
Posted: Thu Jul 04, 2002 11:39 pm Post subject: |
|
|
Great that worked, thanks. |
|
Back to top |
|
|
Techie2000 Guru
Joined: 16 May 2002 Posts: 344
|
Posted: Fri Jul 05, 2002 5:51 pm Post subject: |
|
|
one of the great things about Linux . Very customizable... |
|
Back to top |
|
|
ee99ee2 Guru
Joined: 18 Jun 2002 Posts: 307 Location: Murfreesboro, TN, USA
|
Posted: Sat Jul 06, 2002 3:24 am Post subject: |
|
|
Here's my very simple one:
Code: | PS1="[\[\033[32m\]\w\[\033[01;00;0m\]]\$ " |
|
|
Back to top |
|
|
Ard Righ Guru
Joined: 24 Jun 2002 Posts: 337 Location: Wellington, NZ
|
Posted: Sat Jul 06, 2002 11:50 am Post subject: |
|
|
When you mention putting that prompt in ~/.bashrc do you mean for each user, for root only, or what ?
Is there one file location that works for all users (including root) and whether it is X or not. |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Sat Jul 06, 2002 4:29 pm Post subject: |
|
|
Ard Righ wrote: | When you mention putting that prompt in ~/.bashrc do you mean for each user, for root only, or what ? | ~ translates to 'home directory'. So that would be for 'each user'.
Quote: | Is there one file location that works for all users (including root) and whether it is X or not. | /etc/profile works for all not including X.
You might investigate 'man bash' for more info, though I'm not aware of a single file for all. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
Ard Righ Guru
Joined: 24 Jun 2002 Posts: 337 Location: Wellington, NZ
|
Posted: Sat Jul 06, 2002 5:15 pm Post subject: |
|
|
ok sweet. There aren't many user accounts on the machines I have, so not a great biggie |
|
Back to top |
|
|
wizy Tux's lil' helper
Joined: 26 May 2002 Posts: 133
|
Posted: Sat Jul 06, 2002 5:49 pm Post subject: "works for all" |
|
|
You could also edit the .bashrc in /etc/skel so when new users are added and it uses that directory as the template, they get the new prompt. |
|
Back to top |
|
|
wyrickre n00b
Joined: 10 Jul 2002 Posts: 27 Location: Colorado Springs, CO
|
Posted: Thu Jul 18, 2002 6:49 am Post subject: Re: Try .bashrc |
|
|
tfoss wrote: | Spark wrote: | Hmm, I put this in /etc/profile but it only works on tty, not in xterm. Can anyone tell me what I have to do to get it working in X? |
Try putting it in your ~/.bashrc.
(If i recall, /etc/profile is read only if its a login shell, not an interactive shell (which xterm things are)... ~/.bashrc is read for both...)
-Ted |
Most (if not all) terminals under X (xterm, gnome-terminal, Konsole, rxvt, etc) support the -ls option that specifies the terminal should run as a "login shell". IIRC, this will cause /etc/profile to get read and executed... If I'm correct, putting your prompt in /etc/profile would then affect all users who run shells that read /etc/profile. |
|
Back to top |
|
|
|