View previous topic :: View next topic |
Author |
Message |
sidesh0w n00b
Joined: 02 May 2002 Posts: 14
|
Posted: Tue Jul 23, 2002 6:04 pm Post subject: |
|
|
You could also create an /etc/bashrc file that would contain all of the stuff that each user would use. Then you could source this in the ~/.bashrc file, but beware that any settings in the ~/.bashrc file will override the /etc/bashrc settings. |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Tue Jul 23, 2002 10:57 pm Post subject: |
|
|
sidesh0w wrote: | You could also create an /etc/bashrc file that would contain all of the stuff that each user would use. Then you could source this in the ~/.bashrc file, but beware that any settings in the ~/.bashrc file will override the /etc/bashrc settings. | You can remove all settings from the ~/.bashrc file (except sourcing /etc/bashrc)
and then change priviledges/ownership of the file so users can't change it. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
mgrab n00b
Joined: 07 Jun 2002 Posts: 4
|
Posted: Thu Jul 25, 2002 2:58 am Post subject: changes to /etc/profile not persistent |
|
|
Sorry if this isn't on topic, but when I edit my /etc/profile, the changes don't seem to be persistent. I can't quite figure this out. It seems that at some point, /etc/profile is generated from the config files in /etc/env.d/, but I don't know when that happens. I have edited my /etc/profile only to have it wiped out/reverted, and I have edited my /etc/env.d/files only to have the changes not take effect.
Anyone know what the deal is?
Thanks,
Matt _________________ ------
to know Jesus is the reason for life |
|
Back to top |
|
|
delta407 Bodhisattva
Joined: 23 Apr 2002 Posts: 2876 Location: Chicago, IL
|
Posted: Thu Jul 25, 2002 3:03 am Post subject: |
|
|
Try putting your changes in /etc/profile.env instead. _________________ I don't believe in witty sigs. |
|
Back to top |
|
|
jmglov Retired Dev
Joined: 03 Aug 2002 Posts: 23 Location: Yokohama, Japan
|
Posted: Wed Aug 21, 2002 2:59 pm Post subject: Re: Extra informative Bash prompt |
|
|
wont-i wrote: |
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.
[...]
This ends up producing a prompt such as the following:
Code: |
[b][color=#BB00BB]Sun Jun 23 00:33:58 EDT 2002[/color]
[color=#00BB00]/usr/src/linux[/color]
[color=#FF5555]wont@calvin:[/color] [color=#5555FF]pts/3:[/color] [color=#55FFFF]23 files[/color] [color=#FFFF00]3.8Mb[/color] ->[/b] |
|
That is quite a bit of info, alright. For those people out there (like myself) that prefer a more minimalistic approach, try:
Code: |
PS1=': \u@\h; '
PS2=': ; '
|
This produces a very simple prompt:
Code: |
: jmglov@harp; echo 'foo
: ; bar' >~/foobar
|
But it has a very cool feature, which is the ability to copy the whole line and paste it into another xterm. Why? The ':' character means ignore, and the ';' character starts a new command. So when you paste a line (or several lines) into an xterm, whatever you have in your prompt between the ':' and the ';' is completely disregarded by the shell. |
|
Back to top |
|
|
dyn0m n00b
Joined: 25 Aug 2002 Posts: 6
|
Posted: Tue Aug 27, 2002 7:43 pm Post subject: |
|
|
i like the default slackware prompt
Code: |
# echo $PS1
\u@\h:\w\$
# echo $PS2
>
|
seeing the date all the time is quite anoying (my opinion) if I want to know the time I type `date` |
|
Back to top |
|
|
jmglov Retired Dev
Joined: 03 Aug 2002 Posts: 23 Location: Yokohama, Japan
|
Posted: Tue Aug 27, 2002 8:35 pm Post subject: |
|
|
dyn0m wrote: | i like the default slackware prompt
Code: |
# echo $PS1
\u@\h:\w\$
# echo $PS2
>
|
seeing the date all the time is quite anoying (my opinion) if I want to know the time I type `date` :) |
Agreed. But I could make the same point about the cwd, as I can (and do) easily type 'pwd'. Plus, xterms can be set up to display the cwd in the title bar of their window.
--Josh _________________ Josh Glover <jmglov@gentoo.org>
Gentoo Developer (http://dev.gentoo.org/~jmglov/) |
|
Back to top |
|
|
dyn0m n00b
Joined: 25 Aug 2002 Posts: 6
|
Posted: Tue Aug 27, 2002 8:42 pm Post subject: |
|
|
jmglov wrote: | dyn0m wrote: | i like the default slackware prompt
Code: |
# echo $PS1
\u@\h:\w\$
# echo $PS2
>
|
seeing the date all the time is quite anoying (my opinion) if I want to know the time I type `date` |
Agreed. But I could make the same point about the cwd, as I can (and do) easily type 'pwd'. Plus, xterms can be set up to display the cwd in the title bar of their window.
--Josh |
true.. but i tink one uses his pwd output more than checking the time |
|
Back to top |
|
|
jmglov Retired Dev
Joined: 03 Aug 2002 Posts: 23 Location: Yokohama, Japan
|
Posted: Tue Aug 27, 2002 8:49 pm Post subject: |
|
|
dyn0m wrote: | true.. but i tink one uses his pwd output more than checking the time |
Then why not have your prompt just show you a listing of all the files in the current directory? This would save *me* a lot of trouble, since the first two commands I issue after changing to a directory are 'pwd' and 'ls'.
;)
--Josh _________________ Josh Glover <jmglov@gentoo.org>
Gentoo Developer (http://dev.gentoo.org/~jmglov/) |
|
Back to top |
|
|
xming Guru
Joined: 02 Jul 2002 Posts: 441
|
Posted: Tue Aug 27, 2002 9:15 pm Post subject: ps1 |
|
|
this is mine:
Code: | \[\033[35m\]\t\[\033[m\]-\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ |
I have been using it for 10 years
xming |
|
Back to top |
|
|
rew n00b
Joined: 28 Aug 2002 Posts: 47 Location: Oregon
|
Posted: Wed Aug 28, 2002 6:52 am Post subject: my current bash prompt |
|
|
i use this w/o the color for users, color coded to each box i work on for root.
Code: | export PS1='[\[\033[01;32m\]\u\[\033[m\] \w]$ '
export PS2=' ...> ' |
_________________ linux-2.4.20 i686 SMP
Tyan Tiger MP
Dual Athlon MP 1600+
512MB EEC (1/4)
PNY Verto 64MB - GeForce4 MX 420
'Cheep-ass NIC, CDRW & DVD' |
|
Back to top |
|
|
RayVan n00b
Joined: 12 Aug 2002 Posts: 40 Location: Houston, Tx
|
Posted: Sat Aug 31, 2002 2:06 am Post subject: |
|
|
Ard Righ wrote: | 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. |
The files in the /etc/skel directory are (or, should be) copied to the home directory of every new user. If you edit the .bashrc in that directory, it will propogate to all new users.
Or, you can give all new users a symlink to every file in that directory (this is what I do). |
|
Back to top |
|
|
scottro Tux's lil' helper
Joined: 13 Apr 2002 Posts: 141 Location: New York City
|
Posted: Sat Aug 31, 2002 3:05 am Post subject: |
|
|
To get something in your bash_profile working for X (This is one I should have known but didn't, someone posted it on gentoo-user) call xterm with the -ls option--this makes it interactive.
For instance, I use Fluxbox (and rxvt) so in my fluxbox menu I have for the actual command
{rxvt -fg white -bg black -ls}
(And the same in the keys file, as I call it with Mod4 and r.)
HTH
Scott |
|
Back to top |
|
|
AnarchE n00b
Joined: 26 Jun 2002 Posts: 24 Location: NJ
|
Posted: Thu Sep 12, 2002 9:51 am Post subject: |
|
|
I'm surprised no one has posted this yet, but here is a really great Bash HOWTO written by the Daniel Robbins (CEO and President of Gentoo) on this page:
http://www-106.ibm.com/developerworks/library/bash2.html
Explains in great detail everything you might need to know about bash scripting.
And here's my prompt:
Quote: | PS1="\[\033[1;34m\][\[\033[1;37m\]\T\[\033[1;34m\]]\[\033[1;34m\][\[\033[1;37m\]\d\[\033[1;34m\]][\[\033[1;37m\]\u\[\033[1;34m\]@\[\033[1;37m\]\H\[\033[1;34m\]]\n[\[\033[1;37m\]\w\[\033[1;34m\]] > \[\033[1;0m\]" |
Which looks like this:
Quote: | [05:45:55][Thu Sep 12][anarche@anarche.org]
[~] >
|
the ~ at the end represents working directory.
Enjoy. |
|
Back to top |
|
|
corporate_gadfly n00b
Joined: 21 Sep 2002 Posts: 29
|
Posted: Thu Sep 26, 2002 2:29 pm Post subject: Re: Extra informative Bash prompt |
|
|
wont-i wrote: |
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\]" |
Will |
Hi Will,
Great prompt to start off with. Secondly, can I suggest changing your to which will have the affect of including hidden files and directories that begin with a period.
And changing to which will have the affect of excluding the size of the .. directory.
Cheers |
|
Back to top |
|
|
Pindrop Apprentice
Joined: 09 Jul 2002 Posts: 165 Location: Virginia, USA
|
Posted: Sat Sep 28, 2002 6:39 am Post subject: |
|
|
How do you customize the /etc/date output with spaces? I can't figure it out. I want something like 'Saturday, September 28, 2002 [2:37 AM]' |
|
Back to top |
|
|
kybber Apprentice
Joined: 25 Jun 2002 Posts: 228 Location: Trondheim, Norway
|
Posted: Tue Oct 01, 2002 1:30 pm Post subject: |
|
|
Pindrop wrote: | How do you customize the /etc/date output with spaces? I can't figure it out. I want something like 'Saturday, September 28, 2002 [2:37 AM]' |
Use ' :
Code: | >date +'%A, %B %d, %Y [%I:%M %p]'
Tuesday, October 01, 2002 [03:29 PM]
|
|
|
Back to top |
|
|
nipplehead n00b
Joined: 09 Aug 2002 Posts: 35 Location: NYU
|
Posted: Mon Oct 21, 2002 10:48 pm Post subject: for laptop users using apm. |
|
|
i saw a similar bash prompt on the forums a while ago that used apm to display the current battery percent at the prompt. This one just goes one further and changes the color of the percent depending on the battery status.
Code: | "\[\033[01;3\`apm|awk '\$2~/on-line/{print "2"; exit}\$5~/high/{print "3"}\$5~/low/{print "1"}'\`m\]\`apm|awk '\$5~/%/{print \$5}\$6~/%/{print \$6}'\` \[\033[01;31m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]" |
If plugged in, it's green, like so:
100% peter@gonzo peter $apm
AC on-line, battery status high: 100%
when on battery power but over 50%, you get a yellow percent:
100% peter@gonzo peter $ apm
AC off-line, battery status high: 100% (2:23)
and when below 50%, you get red. (don't feel like running by battery down to get it, but would look like this):
45% peter@gonzo peter $
this going to be my prompt for a while till i find something better for my laptop. _________________ System: Thinkpad T30, P4-m 1.8GHz, 1024MB RAM
To Do: winmodem. grr. lexmark 3200 = winprinter. grr. |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Fri Oct 25, 2002 4:56 pm Post subject: |
|
|
kanuslupus wrote: | /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). | I never really liked that prompt, but wasn't compelled to updated it. I finally did, and now have two prompts; one for root, and one for users. They both look the same, though only the root prompt uses color. user is red, hostname is yellow on a black background. The # is the line for input.
Code: | <carriage return>
[user@hostname pty/s0]/usr/portage
# |
Code: | PS1="\n[\[\033[1;31m\]\u\033[0m\]@\033[1;33m\]\h\033[0m\] \$(/usr/bin/tty | /bin/sed -e 's:/dev/::')]\w\n# " |
users Code: | PS1="\n[\u@\h \$(/usr/bin/tty | /bin/sed -e 's:/dev/::')]\w\n# " |
_________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
tyreth Apprentice
Joined: 27 May 2002 Posts: 238 Location: Melbourne, Australia
|
Posted: Tue Oct 29, 2002 11:35 am Post subject: |
|
|
Is there a way for a user to set up a bashrc file or something that is used for both normal logins and for shells running under X? It seems a bit silly to me that logging in a terminal reads /etc/profile, but logging in a shell reads ~/.bashrc
How can I have it read ~/.bashrc everwhere I log in, so I can have unique settings for my user that work no matter where I open a shell or console? |
|
Back to top |
|
|
hudsonhauck Apprentice
Joined: 16 May 2002 Posts: 182 Location: Albany, CA
|
Posted: Sat Nov 09, 2002 2:56 am Post subject: |
|
|
/etc/profile isn't auto-generated to the best of my knowledge (or at least it has never happened to me ) Make sure you are editing it as root, otherwise you wont' be able to write your changes. _________________ Matthew Hauck
http://matthauck.blogspot.com/ |
|
Back to top |
|
|
corporate_gadfly n00b
Joined: 21 Sep 2002 Posts: 29
|
Posted: Sat Nov 09, 2002 3:40 pm Post subject: |
|
|
hudsonhauck wrote: | /etc/profile isn't auto-generated to the best of my knowledge (or at least it has never happened to me ) Make sure you are editing it as root, otherwise you wont' be able to write your changes. |
You are correct only /etc/profile.env is auto-generated. /etc/profile in turn sources in /etc/profile.env. |
|
Back to top |
|
|
iKiddo Guru
Joined: 27 Jun 2002 Posts: 341 Location: Europe?
|
Posted: Sat Nov 09, 2002 9:28 pm Post subject: |
|
|
tyreth wrote: | Is there a way for a user to set up a bashrc file or something that is used for both normal logins and for shells running under X? It seems a bit silly to me that logging in a terminal reads /etc/profile, but logging in a shell reads ~/.bashrc
How can I have it read ~/.bashrc everwhere I log in, so I can have unique settings for my user that work no matter where I open a shell or console? |
What I do is moving everything to /etc/profile and link my .bashrc to /etc/profile.
This is my prompt:
*[22:07@vc/1:etc]
Code: | NONE='\[\033[00m\]'
GRN='\[\033[01;34;34m\]'
WHT='\[\033[01;37;37m\]'
RED='\[\033[01;31;31m\]'
HBLU='\[\033[01;32m\]'
YEL='\[\033[01;33m\]'
PS1=$GRN'*'$NONE'['$RED'\A'$WHT'@'$HBLU'vc/'\l'$WHT':'$YEL'\W'$NONE']'$NONE' ' |
The green asterisk is for root, users have the same prompt except for the asterisk. Also "etc" is the currentdirectory. You should ofcourse view this against a black (dark) background or you won't see the bracket's, @-sign and colon.
I don't like the xterm console, so I use the 'normal' console on ALT-F1 etc. that's why I have the time and console# displayed in the prompt. |
|
Back to top |
|
|
orangediwontregister n00b
Joined: 19 Nov 2002 Posts: 1
|
Posted: Tue Nov 19, 2002 4:27 am Post subject: |
|
|
can a similar script be use in /etc/profile? |
|
Back to top |
|
|
OdinsDream Veteran
Joined: 01 Jun 2002 Posts: 1057
|
Posted: Fri Nov 22, 2002 2:28 am Post subject: |
|
|
The default prompts are read from the file /etc/profile right? It seems this file has two PS1 settings, one for the root user, and another one for other users.
I can't figure out, though, looking at these two examples, how the "#" gets printed at the end of root's prompt, both when root logs in, and if you su to root.
The two exports are:
Code: |
for root:
export PS1='\[\033[01;31m\]\h \[033[01;34m\]\W \$ \[\033[00m\]'
for others:
export PS1='\[\033[01;32m\]\u@\h \[033[01;34m\]\W \$ \[\033[00m\]'
|
So, according to these, it looks like the prompts both end with $. Of course, this isn't the case.
I tried using the prompt code above, to replace these two export commands, but then I lose the # sign at the end of the root prompts. I can't figure out how to code this. Any tips? Where's this coming from in the default settings? |
|
Back to top |
|
|
|