LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   .bashrc problems (https://www.linuxquestions.org/questions/slackware-14/bashrc-problems-914640/)

grimix 11-21-2011 02:19 AM

.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


grimix 11-21-2011 02:38 AM

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.

ottavio 11-21-2011 04:04 AM

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

Code:

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


David the H. 11-21-2011 10:11 AM

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.


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