LinuxQuestions.org
Review your favorite Linux distribution.
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 11-21-2011, 02:19 AM   #1
grimix
LQ Newbie
 
Registered: Nov 2011
Distribution: Slackware 13.37 32bit
Posts: 3

Rep: Reputation: Disabled
.bashrc problems


For some reason my ~/.bashrc file is not remembered after closing a terminal.

Here is my .bashrc file.
Code:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
HISTCONTROL=$HISTCONTROL${HISTCONTROL+:}ignoredups
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoreboth
HISTFILESIZE=0
HISTSIZE=10
# append to the history file, don't overwrite it
shopt -s histappend

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
	# We have color support; assume it's compliant with Ecma-48
	# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
	# a case would tend to support setf rather than setaf.)
	color_prompt=yes
    else
	color_prompt=
    fi
fi


unset color_prompt force_color_prompt


# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    #alias grep='grep --color=auto'
    #alias fgrep='fgrep --color=auto'
    #alias egrep='egrep --color=auto'
fi

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'

alias teather='adb forward tcp:8080 tcp:8080'

#alias nintendo='fceux --inputdisplay 1'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi
 
Old 11-21-2011, 02:38 AM   #2
grimix
LQ Newbie
 
Registered: Nov 2011
Distribution: Slackware 13.37 32bit
Posts: 3

Original Poster
Rep: Reputation: Disabled
The reason i think that is because when i run alias
Code:
alias teather='adb forward tcp:8080 tcp:8080'
the above no longer shows up in the list of aliases.
 
Old 11-21-2011, 04:04 AM   #3
ottavio
Member
 
Registered: Nov 2007
Posts: 312

Rep: Reputation: 46
~/.bashrc file does not need "remembering". Make sure you have this line in ~/.bash_profile:

Code:
if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi
 
Old 11-21-2011, 10:11 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Is it only that one alias that's not appearing, or is it everything in the file? Is this during login, any time you open a console, or what? Could you please explain step-by-step what you're doing and the results you get?

As mentioned, shells do not "remember" anything. Whenever any process closes, the environment that went with it gets deleted along with it. That's why you need configuration files like bashrc; to reload a default environment into a new shell when it starts.

So if your alias, or whatever, isn't available, it's either because the file itself isn't being loaded at start-up, or the contents are misconfigured in some way and some of the commands fail to execute properly.

As a quick test, try adding a line like echo "~/.bashrc loaded" at the end. If it shows up in the terminal at start-up, then the file itself is loading properly.

Be aware that different configuration files are sometimes called for different shell instances. See the invocation section of the bash man page for more on which files get called in which circumstances.

Finally, did you see this section?

Code:
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi
The bashrc above is already set up to import (source) a list of aliases from a separate file, if it exists. So you might want to do what it suggests and put all your aliases in ~/.bash_aliases instead of the main file. Of course the importing will only be done if the bashrc gets exectuted, so make sure that's working first.
 
  


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] Problems with .bashrc /commands arent working. davestom Linux - Newbie 3 09-19-2009 07:00 AM
.bashrc for su problems m3lkor001 Slackware 1 11-30-2007 08:28 AM
Setting path: /etc/profile, /etc/bashrc or ~/.bashrc Swakoo Linux - General 1 08-07-2007 10:59 PM
problems with .bashrc mocke Linux - Software 6 05-12-2006 05:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:40 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration