SlackwareThis Forum is for the discussion of Slackware Linux.
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.
Distribution: Slackware64-current on Thinkpad Carbon X1
Posts: 264
Rep:
bashrc ??
Can someone show me your .bashrc config... I have heard of many possible tweaks. I have seen many bits and pieces of code but would love to see one that complete and elaborate etc...
What kind of .bashrc (remember the dot in the beginning, it belongs to the filename)? .bashrc is basically just a file where you collect your aliases and stuff that you wish to be set every time you login, which bash then reads, so basically what you can and want to put in there is just about everything you can define using variables, aliases etc. in bash.
Like this: a simple basic .bashrc could be as follows:
Code:
alias ll="ls -al --color"
alias nautilus="nautilus --no-desktop"
alias aterm="aterm -fg white -tr"
export PS1='\u[\W]\$ '
export PAGER="most"
.bashrc contains any command you want to run when you launch any terminal. It should be used for setting aliases, setting environmental variables, or running daemons.
Here is my entire .bashrc file for an example.
Code:
anthony@Pismire:~$ cat .bashrc
# Set the values for some environment variables:
export MINICOM="-c on"
export MANPATH=/usr/local/man:/usr/man:/usr/X11R6/man
export HOSTNAME="`cat /etc/HOSTNAME`"
export LESSOPEN="|lesspipe.sh %s"
export LESS="-M"
export LC_ALL="en_US.utf8"
export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE=xim
export QT_IM_MODULE=xim
export MPD_PORT="6600"
export MPD_HOST="Pismire"
export CFLAGS="-march=pentium3 -O2 -fomit-frame-pointer -fno-ident -pipe"
export CXXFLAGS="${CFLAGS}"
alias fbmplayer='mplayer -fs -x 800 -y 600 -zoom'
# If the user doesn't have a .inputrc, use the one in /etc.
if [ ! -r "$HOME/.inputrc" ]; then
export INPUTRC=/etc/inputrc
fi
# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"
# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH. Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
if [ ! $? = 0 ]; then
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
fi
fi
# I had problems using 'eval tset' instead of 'TERM=', but you might want to
# try it anyway. I think with the right /etc/termcap it would work great.
# eval `tset -sQ "$TERM"`
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
TERM=linux
fi
# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
VISUAL=emacs
# VISUAL=gmacs
# VISUAL=vi
fi
# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
if [ "$SHELL" = "/bin/pdksh" ]; then
PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
PS1='! ${PWD/#$HOME/~}$ '
elif [ "$SHELL" = "/bin/zsh" ]; then
PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
PS1='$ '
else
PS1='\u@\h:\w\$ '
fi
PS2='> '
export PATH DISPLAY LESS TERM PS1 PS2
# Default umask. A umask of 022 prevents new files from being created group
# and world writable.
umask 022
# Set up the LS_COLORS and LS_OPTIONS environment variables for color ls:
if [ "$SHELL" = "/bin/zsh" ]; then
eval `dircolors -z`
elif [ "$SHELL" = "/bin/ash" ]; then
eval `dircolors -s`
else
eval `dircolors -b`
fi
# Notify user of incoming mail. This can be overridden in the user's
# local startup file (~/.bash.login or whatever, depending on the shell)
if [ -x /usr/bin/biff ]; then
biff y
fi
# 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
# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
PATH="$PATH:."
fi
export PSPDEV="/usr/local/pspdev"
export PATH="$PATH:$PSPDEV/bin"
# user added binds to special keys:
# <Alt>+w to show all possible completions for a command from history.
bind '"\M-w"':"\"\C-k\C-ahistory | grep '^ *[0-9]* *\C-e.'\C-m\""
It can be useful as a history search. You know you copied something but lost the links. cp <Alt>+w brings up a list of cp commands from your history.
~/.bash_profile: generally used to provide specific support related to logging in, and for local/personal environment variables and startup programs called only during the login process.
~/.bashrc: generally used for anything local/personal and peculiar to the user’s shell environment.
So, couldn't one customize the .bash_profile with the elements they want to be present when logging in, and then include the following in the .bashrc so that the same customizations are present when opening a new terminal?
No, i don't think you're missing the point. I was looking for the best way to have the customizations applied when logging in, and also when opening a new terminal.
On my current system, I have the .bash_profile customized, and the .bashrc set to source the .bash_profile file. My customizations are set when logging in, but when I open a new tab in my terminal (mrxvt), they are not. This may, however, have more to do with the config settings on my terminal that either the .bashrc or .bash_profile files.
Not closing applications when you close the terminal
The most annoying feature of bash if that it close all applications lauched from a terminal if you close this terminal. A work around is to add the following command to your .bashrc
PROMPT_COMMAND='disown -a -h'
Since I do not like the comportement of bash; I have patch it. After having applying my patch, you will see a new option (hupbgjobs, that you can set with with shopt). Bash then have the following, in my opinion more consistent behaviour:
if huponexit is unset; then application lauched from the shell will not be closed when you close the terminal, even if those applications are in the foreground.
if huponexit is set and hupbgjobs is unset; the applications launched from the shell are closed only if these are in the foreground (default behaviour of tcsh)
if huponexit is set and hupbgjobs is set; then all applications will be closed when the shell exit.
@oliv: that sounds similar to screen's capabilities.
It can also keep processes alive even when you kill your bash.
I know screen; but its purpose is a little different; when you close the terminal the shell continue to run and you can resee it with reattaching. If you want to kill your bash you have explicitly to exit from it. If you have left screen in the background and kill it (killall screen); all applications launched from it will be killed.
What I want is that if a process run in the background, it continue to live whatvever I do with the xterm, the shell, screen, or so...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.