LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 12-28-2002, 02:56 PM   #1
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,966
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Slack and .bashrc


Hi guys,

not that it's a big deal, but I
keep wondering ...

My bash won't evaluate .bashrc, but
if I copy the file to .bash_login it works
fine ... this is a bit odd? :)

Cheers,
Tink
 
Old 12-28-2002, 03:05 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,966
Blog Entries: 11

Original Poster
Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Nope, it's not odd!

Since all your terminals are login-shells .bashrc
is never going to be evaluated for you :}

Cheers
 
Old 12-29-2002, 03:05 AM   #3
Aussie
Senior Member
 
Registered: Sep 2001
Location: Brisvegas, Antipodes
Distribution: Slackware
Posts: 4,590

Rep: Reputation: 56
.bashrc will come into play (so to speak) when you open a terminal emulator such as konsole, eterm or aterm when logged in to a user account in X, if you want to have some system wide variables or aliases you can put them in /etc/profile.
 
Old 12-29-2002, 04:56 AM   #4
MasterC
Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 64
Recently I started messing with aliases. I've always read to put these into a .bashrc file. Since my slack didn't have one, I just created it and added my 2 aliases in it. In order for it to work I have to first:
source .bashrc

Then it works. I am wondering where I should put these files (or entries) to make then work without having to source my bashrc each time I login.

Cool
 
Old 12-30-2002, 09:15 AM   #5
NSKL
Senior Member
 
Registered: Jan 2002
Location: Rome, Italy ; Novi Sad, Srbija; Brisbane, Australia
Distribution: Ubuntu / ITOS2008
Posts: 1,207

Rep: Reputation: 46
/etc/profile or /etc/profile.d/yourscript.sh but make sure its executable and invoked by /etc/profile. For simplicity sake you can just stick your aliases at the ned of /etc/profile and they will be made global.
If you want it for only one use put it in ~/.bash_login or create a script in /etc/profile.d/script.sh that will check for UID and if UID is that of your user it will use the aliases, otherwise it will ignore them. I use something similar to check if UID is 0, and in case it is it will color the prompt RED to make it evident i'm root right away and that i shouldn't do anything stupid.
If you are interested in my script (very basic, as im unable to create anything usefult yet) e-mail me.
And BTW, merry christmas and a happy new year to everyone.
-NSKL
 
Old 01-04-2003, 07:43 AM   #6
fskmh
Member
 
Registered: Jun 2002
Location: South Africa
Distribution: Slackware64-current multilib
Posts: 235

Rep: Reputation: 55
The global profile (/etc/profile) should only have evironment variables that make sense for all users to have. If a specific user has specialised needs it is better to put these into .profile in the user's home dir. Additionally, ~/.profile is read during a console login, so things like coloured prompts should really go in there.
 
Old 12-03-2003, 06:12 PM   #7
GATTACA
Member
 
Registered: Feb 2002
Location: USA
Distribution: Fedora, CENTOS
Posts: 201

Rep: Reputation: 32
Here's my work around on my Slackware 9.1 system:

1) Create your own global aliases in a new file called: /etc/bashrc
2) cd /etc/profile.d
3) Create this script (I call it bashrc.sh)
#!/bin/sh
source /etc/bashrc
4) Save it, and then make it executable: chmod 755 /etc/profile.d/bashrc.sh

Next time you open a terminal your global aliases in /etc/bashrc will be read.

HTH.
 
Old 12-28-2003, 11:52 AM   #8
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 45
Quote:
Originally posted by MasterC
I am wondering where I should put these files (or entries) to make then work without having to source my bashrc each time I login.
Did you decide on a solution for this?

I put { alias ls='ls --color' } in .bashrc, in .profile, and at the end of /etc/profile. (without the curly braces.)

Edit: Oh, and I also tried putting { source ~/.bashrc } in .bash_profile .

The color works when I first log in just from having it in the .bashrc, but once I startx and open xterm or gnome-terminal, the color is gone.

Shouldn't this be doable without having to write some script?

Thanks...

(hey.. I thought Tinkster and MasterC had all the answers!!! )


Last edited by itsjustme; 12-28-2003 at 12:27 PM.
 
Old 12-28-2003, 12:21 PM   #9
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 46
Quote:
Originally posted by MasterC
Recently I started messing with aliases. I've always read to put these into a .bashrc file. Since my slack didn't have one, I just created it and added my 2 aliases in it. In order for it to work I have to first:
source .bashrc

Then it works. I am wondering where I should put these files (or entries) to make then work without having to source my bashrc each time I login.
you shouldn't have to source .bashrc every time, only once. all my user specific settings and aliases are in their respective ~/.bashrc (including root's in /root), and once i source them once, they work everytime i log in to that account, whether in X or at a non-X tty terminal, or even if ssh-ing into the system.
 
Old 12-28-2003, 12:24 PM   #10
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 45
Quote:
Originally posted by synaptical
once i source them once, they work everytime i log in to that account, whether in X or at a non-X tty terminal, or even if ssh-ing into the system.
Well, aren't you special!


(oops, sorry about that... )
 
Old 12-28-2003, 12:35 PM   #11
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 46
Quote:
Originally posted by itsjustme
Well, aren't you special!
well, yes i am but aside from that, i was only trying to show how it worked on one system for comparison. i have no idea why it works, but the fact that it does means that it can. come to think of it, you might need "source ~/.bashrc" in ~/.bash_profile for it to "take" every time you login.

---------------------------
this might be helpful:

Setting the PS? Strings Permanently

Various people and distributions set their PS? strings in different places. The most common places are /etc/profile, /etc/bashrc, ~/.bash_profile, and ~/.bashrc . Johan Kullstam (johan19@idt.net) writes:

the PS1 string should be set in .bashrc. this is because non-interactive bashes go out of their way to unset PS1. the bash man page tells how the presence or absence of PS1 is a good way of knowing whether one is in an interactive vs non-interactive (ie script) bash session.

The way i realized this is that startx is a bash script. what this means is, startx will wipe out your prompt. when you set PS1 in .profile (or .bash_profile), login at console, fire up X via startx, your PS1 gets nuked in the process leaving you with the default prompt.

One workaround is to launch xterms and rxvts with the -ls option to force them to read .profile. but any time a shell is called via a non-interactive shell-script middleman PS1 is lost. system(3) uses sh -c which if sh is bash will kill PS1. a better way is to place the PS1 definition in .bashrc. this is read every time bash starts and is where interactive things - eg PS1 should go.

Therefore it should be stressed that PS1=..blah.. should be in .bashrc and not .profile.

http://www.dreaming.org/~giles/bashp...wto/setps.html

so maybe it's the same thing for aliases getting nuked?

pps., adding -F to the ls alias is a cool little feature also. it gives you a symbol next to the file when it's of a certain kind, e.g., * for executable, @ for a symlink, etc.
alias ls='ls -F --color'

Last edited by synaptical; 12-28-2003 at 12:53 PM.
 
Old 12-28-2003, 12:50 PM   #12
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 45
Yeah, I edited my post to indicate that I did put { source ~/.bashrc } in .bash_profile, but it had no effect in either xterm on gnome-terminal after logging out and in and then once I had x started.

I am running WindowMaker on that machine. What do you run when you startx ? Maybe you could grep out an { ls --color } on your system to see where it's set?

Thanks...
 
Old 12-28-2003, 01:04 PM   #13
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 46
Quote:
Originally posted by itsjustme
Yeah, I edited my post to indicate that I did put { source ~/.bashrc } in .bash_profile, but it had no effect in either xterm on gnome-terminal after logging out and in and then once I had x started.

I am running WindowMaker on that machine. What do you run when you startx ? Maybe you could grep out an { ls --color } on your system to see where it's set?
well it gets a bit complicated at this point, because i not only don't startx, i startxfce4, and actually i don't even startxfce4 anymore, i have a ~/.bashrc alias for startxfce4 called "gui." but i just tried it and my aliases work if i startx into gnome or fluxbox.

so your guess as to what is going on is as good as mine.

grep ls --color didn't give anything, maybe because i use the -F option (?). but i have all aliases like that in the ~/.bashrc for each user, and it seems to be working.
 
Old 12-28-2003, 06:26 PM   #14
core
Member
 
Registered: May 2003
Location: Berlin
Distribution: Slackware 9.1 Kernel: 2.6.4
Posts: 60

Rep: Reputation: 15
Code:
me@core:~$ ll .bash*
-rw-------    1 me  users        8,9K 2003-12-28 23:37 .bash_history
lrwxrwxrwx    1 me  users           7 2003-12-12 12:30 .bash_login -> .bashrc
-rw-------    1 me  users         565 2003-12-28 08:55 .bashrc
me@core:~$ cat .bashrc 

alias pico=nano
alias ll='ls -lh'
alias la='ls -Alh'
alias links='links -driver fb'

eval `dircolors`
VISUAL=/usr/local/bin/nano

case $TERM in
  xterm*)
        PROMPT_COMMAND='echo -ne "\033]0;${USER}:${PWD}\007"'
        PS1="[\033[0;37m\]\u\[\033[0;32m\]@\[\033[0;37m\]\h\[\033[0;32m\]:\[\033[1;33m\]\w\[\033[0;32m\]\$\[\033[0;37m\] "
        ;;
  screen*)
        PS1="\[\033[0;37m\]\u\[\033[0;32m\]@\[\033[0;37m\]\h\[\033[0;32m\]:\[\033[1;33m\]\w\[\033[0;32m\]\$\[\033[0;37m\] "
        ;;
  *)
        PROMPT_COMMAND=''
        PS1="\u@\h:\w\$ "
  ;;
esac

export VISUAL PROMPT_COMMAND
This just works like a charm

Edit: note that the forum breaked the PS1 lines.. actially it's just one line.

Last edited by core; 12-28-2003 at 06:32 PM.
 
Old 12-28-2003, 07:38 PM   #15
kiko
Member
 
Registered: Dec 2003
Posts: 47

Rep: Reputation: 15
Below is an excerpt of "bash.SlackBuild":

CFLAGS="-O2 -march=i486 -mcpu=i686" \
./configure --prefix=/usr i486-slackware-linux
make
make install DESTDIR=$PKG

It seemed it is clean, I used to modify my .bash_profile, .bashrc for use in slackware as well as in redhat. I've only 1 root subdir shared among diverse distros or releases of slackware.

Redhat seemed not only have the "--prefix=.." on its configure arguments. So thing get something choastic after I merged redhat's (~/.bash*,/etc/{profile,bashrc}) with my config for slackware, but after sometime I forgot wut is specific for redhat n wut for slack. But now I use almost EXCLUSIVELY slack, so I don't wonna spend $TIME for other distro ..

"man bash" should give good advice on bash* config, redhat might need extra attention on the place/order for reading the resource files (check the argument of ./configure).

Actually I heard sh/bash is not that excellent regarding their semantic/syntax compared to tcsh or ksh, wonder why so much ppl use it excusively ..

-------
Booster for Ka+pumper between nerits n dendrites ?
cafein, glutamat acid but not ectaxi
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does Slack have an equivalent to .bashrc? thorney Slackware 7 11-26-2005 01:08 PM
Slack 9.1 won't read /etc/bashrc GATTACA Slackware 18 11-15-2004 10:23 AM
bashrc nobu Slackware 6 03-21-2003 10:53 AM
.bashrc help envirodug Linux - Newbie 2 06-14-2001 11:00 PM
.bashrc prasad Linux - General 1 04-14-2001 09:51 AM


All times are GMT -5. The time now is 12:16 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration