Quantcast
Channel: bash – Wayno's Adventures and Sojourns through Linux
Viewing all articles
Browse latest Browse all 11

Sample .bashrc script

$
0
0

A lot of people have asked for a sample .bashrc script. This is nothing fancy. It exits if the script is not executed interactively, turns on the colour prompts, sources .bash_aliases, adds /usr/sbin so some commands are executable (for debian mostly)


#!/bin/bash

#-------------------------------------------------------------
# Wayno's .bashrc script
# v 3.0 11/05/2017
#-------------------------------------------------------------

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

#-------------------------------------------------------------
# Source global definitions (if any)
#-------------------------------------------------------------

#-------------------------------------------------------------
# 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 ]; then
. /etc/bash_completion
fi

#-------------------------------------------------------------
# add .bashrc.local wayno 05/20/2009
#-------------------------------------------------------------

if [ -r /etc/bash.bashrc.local ]; then
. /etc/bash.bashrc.local
fi

#-------------------------------------------------------------
# enable bash_aliases GU 12/1/2008
# if bash.bashrc.local exists, use it
#-------------------------------------------------------------

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

#-------------------------------------------------------------
# Turn on colour prompt
#-------------------------------------------------------------

# 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

#-------------------------------------------------------------
# if colour prompt on, make the bash prompt working directory
#-------------------------------------------------------------

if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

#-------------------------------------------------------------
# make default start directory the home directory of the user
#-------------------------------------------------------------

cd $HOME

#-------------------------------------------------------------
# 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.
#-------------------------------------------------------------

alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

export HISTTIMEFORMAT="%h/%d - %H:%M:%S "

#-------------------------------------------------------------
# add sbin GU 06/10/2012 (fix up the path so we can execute
# some commands)
#-------------------------------------------------------------

export PATH=$PATH:/sbin:/usr/sbin:/usr/sbin

export PATH=$PATH:/snap/bin

unset color_prompt force_color_prompt


Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images