LinuxQuestions.org
Register a domain and help support LQ
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 05-02-2014, 11:38 PM   #1
hottdogg
Member
 
Registered: Aug 2004
Location: aisenodni
Distribution: slackware 64bit ,debian 64bit
Posts: 202

Rep: Reputation: 30
Slackware shell config help


This is a simple problem but I just can't get my head around with .
Too stupid

Problem is I want to have my interactive shell(kde konsole) to have same 'more-colorful' like in login shell so I put /etc/profile in my .bashrc.
And I want login shell has same config as interactive shell.

Here's my ~/.bashrc
Code:
. /etc/profile #the dilemma line
alias grep='grep --color'
export GREP_COLOR=';32'
export APP_MODE='development'

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
my ~/.bash_profile
Code:
if [ -f ./.bashrc ]; then
    source ./.bashrc
fi
The problem with this is the fortune is run twice when I login through shell(I dont use gui login), because /etc/profile is invoked twice by login shell. And I don't want this,seems dirty and odd.

I put a diagram for you...
Code:
login-shell             
 ^         ^ 
 |          \
 |           \
.bash_profile \
 ^             /etc/profile 
 |
 |
.bashrc
 ^
 |
 |
/etc/profile

interactive shell
  ^
  |
  |
.bashrc
  ^
  |
  |
/etc/profile
Can you guys give me advice for this?

Last edited by hottdogg; 05-02-2014 at 11:40 PM.
 
Old 05-02-2014, 11:59 PM   #2
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534
When I had my web site running I had a nice how-to about harmonizing the bash scripts. If anybody is interested in moving that how-to the slackware.docs site, contact me and I'll forward the text.

In the mean time, try this:

Code:
# ~/.bash_profile
#
# Local/Personal aliases and functions go here
if [ -f $HOME/.bashrc ]; then
  source $HOME/.bashrc
fi

# Local/Personal startup programs go here
Code:
# ~/.bashrc
#
# System-wide aliases and functions go here
if [ -f /etc/bashrc ]; then
  source /etc/bashrc
fi

# Local/Personal environment variables go here
# Define bash prompts, non-X text editors, etc.
unset MAILCHECK

# --- Local aliases ---

# --- Local functions ---
 
Old 05-03-2014, 01:02 AM   #3
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 755

Rep: Reputation: 226Reputation: 226Reputation: 226
You want Konsole to give you a shell like the one when you log in at boot?

Just change the setting in konsole

Settings -> Edit Current Profile
Change "Command:" from "/bin/bash" to "/bin/bash -ls"
Click Apply

The "-ls" on the end of the command tells bash you want to invoke it as if you were logging in and will execute the same scripts giving you the exact same environment.
 
1 members found this post helpful.
Old 05-03-2014, 02:31 AM   #4
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,388

Rep: Reputation: 1090Reputation: 1090Reputation: 1090Reputation: 1090Reputation: 1090Reputation: 1090Reputation: 1090Reputation: 1090
Instead of sourcing /etc/profile, just cherry pick what you need in it and copy/paste that in ~/.bashrc. In addition, possibly run only (parts of) the scripts in /etc/profile.d that you need.
 
Old 05-03-2014, 07:51 AM   #5
eloi
Member
 
Registered: Nov 2010
Posts: 210

Rep: Reputation: 55
And Didier is right again.

It's the second time someone has the crazy idea of sourcing /etc/profile form
~/.bashrc

By the way. If you don't want the fortune message do this:

# chmod -x /etc/profile.d/bsd-games-login-fortune.sh


Jaime Sommers
Schoolteacher
 
Old 05-03-2014, 08:07 AM   #6
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,079

Rep: Reputation: 794Reputation: 794Reputation: 794Reputation: 794Reputation: 794Reputation: 794Reputation: 794
It's a Real Good Idea to leave /etc/profile alone; i.e., don't ever edit it (it's system-wide).

For customization, system-wide, you can add files to /etc/profile.d. For personal customization, you can add a ~/.profile file in your home directory and you can add ~/.bashrc file as well.

Now, why would you want to do things like that?

Well, the sequence when you log in is execute (in this order)
  • /etc/profile
  • /etc/profile.d/<files relevant to the shell program you're using and other executable files there>
  • /home/your_id/.profile
  • /home/your_id/.bashrc
At the bottom of /etc/profile, you'll find this:
Code:
# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
unset profile_script
That's what executes the stuff in /etc/profile.d. Some of those files are shell-specific (BASH, KornShell, C-Shell, etc.), some are system-wide (setting Java environment and the like).

All that happens once at log in and it happens when you open a terminal window as a "log in shell" which is what you typically want -- you get all the environment settings, aliases you like and all that sort of thing.

Hope this helps some.
 
Old 05-03-2014, 08:22 AM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,290
Blog Entries: 3

Rep: Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446Reputation: 1446
Member Response

Hi,

I like to provide my users with this;
Quote:

Code:
sample .bash_profile;   
~$ cat .bash_profile 
#-----------------cut-----------------   
# .bash_profile
#08-30-06 12:21

# Source .bashrc
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

#-----------------cut end--------------

Code:
 cat .bashrc
#-----------------cut-------------------

#.bashrc
#08-30-06 12:20 

# Add bin to path
export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize
#
#save bash history so as to share

shopt -s histappend
PROMPT_COMMAND='history -a'

# Custom prompt 
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 
#08-29-06 11:40 gws 
if [ `id -un` = root ]; then 
PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] ' 
else
PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] ' 
fi 
# 
# Add color 
eval `dircolors -b` 
#Terminus is a very nice Unicode font for the Linux console
#02-02-12 gws
#from dugan's site http://duganchen.ca/writings/slackware/fonts/

#04-30-12 11:41 removed
#
#if [ $TERM = "linux" ]; then
# setfont ter-v16n
#fi

# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/ www.google.com'

#08-29-06 11:50

#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
 trap "rm -f ~$LOGNAME/.bash_history" 0

#The older KSH-style form
#trap 0 rm -f ~$LOGNAME/.bash_history


#-----------------cut end--------------
I let them modify to suit their needs.
Hope this helps!
 
Old 05-04-2014, 08:01 AM   #8
eloi
Member
 
Registered: Nov 2010
Posts: 210

Rep: Reputation: 55
Just for fun

Just for fun and off topic. This is my bash prompt.

Code:
function bg_jobs
{
	jobs | wc -l | grep -v 0 | sed "s/.*/[&]/"
}

PS1=''
case "$TERM" in
*xterm*|*rxvt*)
	# Window Title
	PS1+='\[\033]2;'
	PS1+='\w'
	PS1+='\007\]'
	# Icon Title
	PS1+='\[\033]1;'
	PS1+='\u@\h:\w'
	PS1+='\007\]'
        ;;
esac
PS1+='\u@\h:'
PS1+='\w'
PS1+='`bg_jobs`'
PS1+='\$ '
With this fashion you can intercalate stuff and colors in a clean way.
 
  


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
[SOLVED] Use shell script to modify kernel config dbrazeau Linux - Kernel 2 08-16-2013 01:10 PM
Sendmail Config--Two mail accounts from one shell user. signalman Linux - Server 10 06-23-2012 10:55 PM
Possible to save grub config directly from shell? jarodm Linux - Newbie 1 07-13-2009 02:15 PM
Shell Script Config Not Working? arew264 Programming 2 01-02-2008 09:42 PM
newbie: how to config shell to display i18l font? sirpelidor Linux - Newbie 1 06-01-2007 08:40 AM


All times are GMT -5. The time now is 10:46 PM.

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