Posted: . At: 9:47 AM. This was 2 years ago. Post ID: 16424
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to include a script in a ~/.bashrc when using Linux.


To include a script in a ~/.bashrc is very simple. Just use either of two methods.

One.

source /usr/share/landscape/landscape-sysinfo.wrapper

Or this simpler method.

. /usr/share/landscape/landscape-sysinfo.wrapper

Either of these methods will work. This is an easy way to include a script in your ~/.bashrc and run it.

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

As seen above the if statement here checks if the file exists before trying to include it. That would be a very good way to do this properly.

Or this example, try 2 separate files.

# 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 ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.