Re: Post your .bashrc!
Right On.
CrunchBang Linux Forums » Tips, Tricks & Scripts » Post your .bashrc!
Right On.
It just keeps getting better.....thanks.
![]()
ggordon
Is it possible to have a different .bashrc for different emulators?
Mine is available on my git repo, nothing amazing, just a few simple aliases and scripts to save me time. Due to the number of systems I use my .bashrc on, i've got numerous entries that detect and enable features as required.
Just found a cool .bashrc tip and didn't want the tip to get lost in this thread, but here's how you can add color man pages.
With a little help from the earlier posts, here's my .bashrc .
# ~/.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'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
export HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# 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
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
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# 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 color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
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
# 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
######################
# CUSTOM STARTS HERE #
######################
# Define a few Colours
BLACK='\e[0;30m'
BLUE='\e[0;34m'
GREEN='\e[0;32m'
CYAN='\e[0;36m'
RED='\e[0;31m'
PURPLE='\e[0;35m'
BROWN='\e[0;33m'
LIGHTGRAY='\e[0;37m'
DARKGRAY='\e[1;30m'
LIGHTBLUE='\e[1;34m'
LIGHTGREEN='\e[1;32m'
LIGHTCYAN='\e[1;36m'
LIGHTRED='\e[1;31m'
LIGHTPURPLE='\e[1;35m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'
NC='\e[0m' # No Color
###########
# Aliases #
###########
# ls
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
# Dir
alias home='cd'
alias documents='cd ~/documents'
alias downloads='cd ~/downloads'
alias linuxdoc='cd ~/linuxdoc'
alias music='cd ~/music'
alias pix='cd ~/pictures'
alias root='sudo -i'
# Sudo
alias install='sudo apt-get install'
alias remove='sudo apt-get remove'
alias purge='sudo apt-get remove --purge'
alias update='sudo apt-get update'
alias clean='sudo apt-get autoclean && sudo apt-get autoremove'
alias sources='(gksudo geany /etc/apt/sources.list &)'
# chmod and permissions commands
alias mx='chmod a+x'
alias 000='chmod 000'
alias 644='chmod 644'
alias 755='chmod 755'
# Misc
alias a='alias'
alias c='clear'
alias h='htop'
alias x='exit'
alias bg='geany ~/.bashrc'
alias pci='lspci'
alias ksf='killall swiftfox-bin'
alias del='rm --target-directory=$HOME/.Trash/'
alias font='fc-cache -v -f'
# Extracting
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
#Automatically do an ls after each cd
cd() {
if [ -n "$1" ]; then
builtin cd "$@" && ll
else
builtin cd ~ && ll
fi
}
##################
# WELCOME SCREEN #
##################
clear
echo -ne "${LIGHTGREEN}" "Hello, $USER. today is, "; date
echo -e "${LIGHTGREEN}"; cal -3; Last edited by NWAdawg (2009-07-10 22:52:09)
i have some 'stuff' in my .bashrc file that i got off this forum, but i mainly use a file called .alias and it works great. just add this to your .bashrc so it will find the .alias file
if [ -e $HOME/.alias ]; then
[ -n "$PS1" ] && . $HOME/.alias
fiand this is my .alias file. i have collected most from the internet and some are mine. if you decide to use some of it make sure you check the folder locations/names and this is for my computer. ![]()
#insert the following at the end of $HOME/.bashrc
# Source the aliases, if a separate file exists
#if [ -e $HOME/.alias ]; then
# [ -n "$PS1" ] && . $HOME/.alias
#fi
#Aliases for improved directory listings
#The --color=tty option shows items in different colors according to their type.
#For example, directories are blue, executable files are green, symlinks are cyan, etc.
#The -F option appends a symbol after entries to indicate their types.
#You might not like both options at the same time.
alias ls='ls -F --color=tty' #regular ls
alias l.='ls -dF .[a-zA-Z0-9]* --color=tty' #only show dotfiles
alias ll='ls -lhF --color=tty' #long listing
alias dir='ls -ba'
#Make these commands ask before clobbering a file. Use -f to override.
alias rm="rm -i"
alias cp="cp -i"
alias mv="mv -i"
#Use human-readable filesizes
alias du="du -h"
alias df="df -h"
#Miscellaneous
alias bzip2='bzip2 -v'
alias j=jobs
alias cd..="cd .." #work around a common typo
#Automatically do an ls after each cd
cd() {
if [ -n "$1" ]; then
builtin cd "$@" && ls
else
builtin cd ~ && ls
fi
}
alias c='clear'
alias e='espeak'
alias kgp='killall gnome-panel'
alias k='kill'
alias kn='killall nautilus'
alias q='exit'
alias movielist='ls /media/ONETOUCH/movies > /home/dave/documents/Movie_List.txt'
alias synaptic='sudo synaptic'
alias yt='youtube-dl -t '
alias mc='metacafe-dl -t'
alias backup='sudo cp /etc/apt/sources.list /home/dave/documents/systemfiles/sources.list | cp /boot/grub/menu.lst /home/dave/documents/systemfiles/menu.lst | cp /etc/X11/xorg.conf /home/dave/documents/systemfiles/xorg.conf | cp ~/.alias /home/dave/documents/systemfiles/.alias | cp ~/.bashrc /home/dave/documents/systemfiles/.bashrc | cp ~/.conkyrc /home/dave/documents/systemfiles/.conkyrc'
alias reload="killall -SIGUSR1 conky"
alias updatefont="fc-cache -v -f"
alias trash="mv -t ~/.local/share/Trash/files --backup=t"
alias ss="gnome-screensaver-command -a"
alias home="cd ~/"
alias documents="cd ~/documents/ | less"
alias downloads="cd ~/downloads/ | less"
alias images="cd ~/images/ | less"
alias pictures="cd ~/images/ | less"
alias music="cd ~/music/ | less"
alias videos="cd ~/videos/ | less"
alias movies="cd ~/videos/Movies | less"
alias projects="cd ~/projects | less"
alias torrents="cd ~/torrents | less"
alias galias='gedit ~/.alias'
alias gconky='gedit ~/.conkyrc'
alias gbash='gedit ~/.bashrc'
alias moc='mocp -T /home/dave/.moc/themes/transparent-background'
alias fb='frozen-bubble'
alias today='date +"%A, %B %-d, %Y"'
alias agi='sudo apt-get install'
alias agr='sudo apt-get remove'
alias agu='sudo apt-get update'
alias agdu='sudo apt-get dist-upgrade'
alias acs='apt-cache search'
alias acsh='apt-cache show'
alias sdi='sudo dpkg -i'
alias agar='sudo apt-get autoremove'
alias agc='sudo apt-get clean'
alias av='apt version'
alias cleanup='sudo apt-get autoclean && sudo apt-get autoremove && sudo apt-get clean && sudo apt-get remove && orphand'
alias colors="./.colors.sh"
#PS1='[\e[01;32m]\u[\e[01;34m] @ \h [\e[01;36m]\w [\e[01;31m]\t\n[\e[01;36m]$ [\e[00m]' #colorfull
PS1='[\w]$ ' #plain and simple
#PS1='\[[\033[01;34m\]\w\[\033[0;37m\]]\$ ' #colored directory
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$' #Green
#PS1='\[[\033[01;34m\]\u@\h\[\033[00m\]]:\[\033[01;34m\]\w\[\033[0;37m\]\$ ' #Blue
#For root add this to /root/.bashrc
#PS1='\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$' #Red
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
# Get weather (replace the 71822 in the url with your own zipcode, call it by typing weather)
weather ()
{
declare -a WEATHERARRAY
WEATHERARRAY=( `elinks -dump "http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=weather+34769&btnG=Search" | grep -A 5 -m 1 "Weather for" | grep -v "Add to "`)
echo ${WEATHERARRAY[@]}
}
# Get weather (replace the 71822 in the url with your own zipcode, call it by typing weather)
weatherny ()
{
declare -a WEATHERARRAY
WEATHERARRAY=( `elinks -dump "http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=weather+13603&btnG=Search" | grep -A 5 -m 1 "Weather for" | grep -v "Add to "`)
echo ${WEATHERARRAY[@]}
}
# Get IP (call with myip)
function myip {
myip=`elinks -dump http://checkip.dyndns.org:8245/`
echo "${myip}"
}the .colors file is a cool script i found and displays all available colors when 'colors' is typed in
#!/bin/bash
#
# This file echoes a bunch of color codes to the
# terminal to demonstrate what is available. Each
# line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
# colors (default + 8 escapes).
#
# Taken from the Bash Prompt HOWTO:
# http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
T='gTk' # The test text
echo -e "\n 40m 41m 42m 43m\
44m 45m 46m 47m";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
do FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
echo;
doneenjoy!
dave.
Just posting the cool stuff:
function apt-history(){
case "$1" in
install)
cat /var/log/dpkg.log | grep 'install '
;;
upgrade|remove)
cat /var/log/dpkg.log | grep $1
;;
rollback)
cat /var/log/dpkg.log | grep upgrade | \
grep "$2" -A10000000 | \
grep "$3" -B10000000 | \
awk '{print $4"="$5}'
;;
*)
cat /var/log/dpkg.log
;;
esac
}From a wiki @ubuntuusers.de
This will give you an apt-history command with install, upgrade, remove and rollback options. Use it like apt-get:
apt-history installSo you can keep track of what you installed, featuring a timestamp.
Last edited by Awebb (2009-07-29 12:01:00)
Here's mine...... ![]()
Enjoy!
[ -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'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
export HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# 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
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
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
#define some crap
rendip=202.124.131.249
# Define a few Color's
BLACK='\e[0;30m'
BLUE='\e[0;34m'
GREEN='\e[0;32m'
CYAN='\e[0;36m'
RED='\e[0;31m'
PURPLE='\e[0;35m'
BROWN='\e[0;33m'
LIGHTGRAY='\e[0;37m'
DARKGRAY='\e[1;30m'
LIGHTBLUE='\e[1;34m'
LIGHTGREEN='\e[1;32m'
LIGHTCYAN='\e[1;36m'
LIGHTRED='\e[1;31m'
LIGHTPURPLE='\e[1;35m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'
NC='\e[0m' # No Color
# 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 color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
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'
# 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
export PS1="${PS1%\\\$*}"' \t \$ '
# cleanup history a bit, make it so that we can share
# a common history between concurrent sessions
export HISTCONTROL=ignoreboth
export HISTSIZE=1000000 HISTFILESIZE=1000000
shopt -s histappend
if [ -n "$PROMPT_COMMAND" ]; then
PROMPT_COMMAND="$PROMPT_COMMAND; history -a"
else
PROMPT_COMMAND='history -a'
fi
# SPECIAL FUNCTIONS
#######################################################
nfind ()
{
nano -w `find . -name "$1"`
}
netinfo ()
{
echo "--------------- Network Information ---------------"
/sbin/ifconfig | awk /'inet addr/ {print $2}'
echo ""
/sbin/ifconfig | awk /'Bcast/ {print $3}'
echo ""
/sbin/ifconfig | awk /'inet addr/ {print $4}'
# /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
echo "---------------------------------------------------"
}
spin ()
{
echo -ne "${RED}-"
echo -ne "${WHITE}\b|"
echo -ne "${BLUE}\bx"
sleep .02
echo -ne "${RED}\b+${NC}"
}
ef () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjvf $1 ;;
*.tar.bz) tar xjvf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
100meg () {
dd if=/dev/urandom of=bigfile bs=1024 count=102400
}
#servers
alias beefy='ssh beefy.xxxxxxxx.com'
alias chunky='ssh chunky.xxxxxxxx.com'
alias webby='ssh webby.xxxxxxxx.com'
alias snappy='ssh snappy.xxxxxxxx.com'
alias ps='ps auxf'
alias home='cd ~'
alias pg='ps aux | grep' #requires an argument
alias un='tar -zxvf'
alias mountedinfo='df -hT'
alias ping='ping -c 10'
alias openports='netstat -nape --inet'
alias ns='netstat -alnp --protocol=inet | grep -v CLOSE_WAIT | cut -c-6,21-94 | tail +2'
alias du1='du -h --max-depth=1'
alias da='date "+%Y-%m-%d %A %T %Z"'
clear
for i in `seq 1 15` ; do spin; done ;echo -ne "${WHITE} Dave's Linux Box ${NC}"; for i in `seq 1 15` ; do spin; done ;echo "";
echo -e "Kernel Information: " `uname -smr`;
echo -e ${LIGHTBLUE}`bash --version`;echo ""
echo -ne "Hello $USER today is "; date
echo -e "${WHITE}"; cal ;
echo -ne "${CYAN}";netinfo;
mountedinfo ;
echo -ne "${LIGHTBLUE}Uptime for this computer is ";uptime | awk /'up/
{print $3,$4}'
for i in `seq 1 15` ; do spin; done ;echo -ne "${WHITE} All your base are belong to us! ${NC}"; for i in `seq 1 15` ; do spin; done ;echo "";
echo ""; echo ""Just posting the cool stuff:
From a wiki @ubuntuusers.de
This will give you an apt-history command with install, upgrade, remove and rollback options. Use it like apt-get:
apt-history installSo you can keep track of what you installed, featuring a timestamp.
hey, i tried that...and every combination i could think of for "apt-history" and no packages were found to install.
clarify? sounds like a great little addition.
^works great here
thanks for sharing Awebb
^^still doesn't work for me......
erik@SMASHBANG:~$ apt-history intall
bash: apt-history: command not found
erik@SMASHBANG:~$ and trying to find 'apt-history' to install?
cannot find package to install. ![]()
and trying to find 'apt-history' to install?
cannot find package to install.
You don't install anything. You add the code that Awebb provided to your .bashrc file and then you can run these commands from a terminal
apt-history install
apt-history upgrade
apt-history remove
apt-history rollback
They provide time stamped output of packages you have recently installed, upgraded, removed or rolledback with apt.
well then..........let me be the first to slap myself silly ![]()
oh, and let me open myself to more laughter at my own expense.........
does this go direct into .bashrc, or into .bash_profile?
Last edited by SmashedGlass (2009-08-10 13:40:56)
does this go direct into .bashrc, or into .bash_profile?
.bashrc
Little off topic but if you are interested in a .zshrc I've posted mine.
Little off topic.
Agreed, let's stick to .bashrc here ![]()
I like a gentoo like feel in my terminal .. oh btw this is my first post... and a new #! convert.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
shopt -s checkwinsize
shopt -s histappend
# Change the window title of X terminals
case ${TERM} in
xterm*|rxvt*|Eterm|aterm|kterm|gnome*|interix)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac
use_color=false
###
# Gentoo Like Terminal
###
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs} ]] \
&& type -P dircolors >/dev/null \
&& match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true
if ${use_color} ; then
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if type -P dircolors >/dev/null ; then
if [[ -f ~/.dir_colors ]] ; then
eval $(dircolors -b ~/.dir_colors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
fi
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi
alias ls='ls --color=auto'
alias grep='grep --colour=auto'
else
if [[ ${EUID} == 0 ]] ; then
# show root@ when we don't have colors
PS1='\u@\h \W \$ '
else
PS1='\u@\h \w \$ '
fi
fiheres mine
# ~/.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
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# 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
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>' #this defines what the prompt looks like.
# PS1='username@hostname:~$'
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac
############################## options ########################################
shopt -s cdspell # This will correct minor spelling errors in a cd command.
shopt -s checkwinsize # Check window after each command
HISTIGNORE="cd:cdl:ls:ll:[bf]g:clear:exit"
export PATH=$PATH:/home/ben/bin
export EDITOR=emacs
export BROWSER=firefox
###################### 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 color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ] && [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -lh --time-style="+%d-%m-%Y %H:%M"' #formats size and time display
alias la='ls -A'
alias l='ls'
alias cpi='cp -i'
alias mvi='mv -i'
alias rmi='rm -i'
alias ~='cd ~/'
alias thesaurus='aiksaurus'
alias thes='aiksaurus'
alias emacs='emacs -nw'
alias emac='emacs -nw'
alias xemacs='\emacs'
alias ccal='cal | grep -C6 --color -e " $(date +%e)" -e "^(date +%e)"'
alias play='mpd && mpc play'
alias ipy='ipython -p sh'
alias note='tnote'
alias bday='calendar -l 365 -f ~/.calendar/calendar.birthdays'
alias apt-get='sudo apt-get install'
alias aptinstall='sudo apt-get install'
alias aptshow='apt-cache show'
alias aptsearch='apt-cache search'
alias ..='cd ../'
alias ...='cd ../../'
alias ....='cd ../../../'
function cdl () { cd $1;ls;} # cd's to a directory then lists contents
function cdla () { cd $1;la;}
function cdll () { cd $1;ll;}
################ Useful functions
function doc() { pushd "/usr/share/doc/$1" && ls;} #goes to doc file for a program
function extract() # Handy Extract Program.
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
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 ]; then
. /etc/bash_completion
fi
################## Start options
function startopts ()
{
if [[ $(date +%p) == 'AM' ]] #%p is either AM or PM called from date
then printf "Good morning $USER. \t\t\t\t" # note echo statements alway end with newline char, printf doesn't
else printf "Good afternoon $USER. \t\t\t\t"
fi
date '+%a %-d %b %Y' #prints date
calendar -l7 -f ~/.calendar/calendar.birthdays #and any birthdays coming up in next 7 days
if [[ $(date +%a) == 'Sun' ]] #recycling reminder
then let "wk = $(date +%W)%2"
if [[ $wk == 1 ]]
then echo Week A: cans, glass bottles, plastic bottles.
else echo Week B: newspaper, plastic bottles, main bin.
fi
fi
}
startoptsand a useful function for python scripters, its separate so i can use it in ipython aswell
#!/bin/bash
#pythonhelp
# setup a host for python documentation and launch a browser for viewing it
pydoc -p 7464&
sleep 0.5
if (( "$#" == 0))
then
w3m http://localhost:7464
else
$1 http://localhost:7464
fi
kill $! #kills background process
echo process $! endedI found this the other day and put it my bashrc. Works like a charm. No messing with setups. It's quick and easy. I'm sure others know this...but in case not...
To share the contents of any folder on your machine simply run:
python -c "import SimpleHTTPServer; SimpleHTTPServer.test();"
and put this in your bashrc:
alias webshare='python -c "import SimpleHTTPServer; SimpleHTTPServer.test();"'
Then on any other machine in your LAN open Firefox point it to port 8000, like http://192.168.1.65:8000, and away you go. It will list the files from the directory you ran the script from so be careful. If you run it from / the the whole system is open.
The url to the posting.
http://ubuntu-tutorials.com/2009/09/01/
th-python/
For the terminal fetishists there is wikipedia2text:
sudo apt-get install wikipedia2textAs alias in .bashrc:
alias wiki='wikipedia2text -p 'well cant find wikipedia2txt
i use this
function wiki() #check wikipedia
{ dig +short txt "${@}".wp.dg.cx | sed -e 's/" "//g' -e 's/^"//g' -e 's/"$//g' -e 's/ http:/\n\nhttp:/' | fmt -w $(tput cols);}well cant find wikipedia2txt
http://manpages.ubuntu.com/manpages/int
ext.1.html
wikipedia2text, you missed the 'e' ![]()
anyway thanks for the function!
Last edited by machinebacon (2009-10-16 00:32:50)
oops, thanks
in my defence neither apt-cache search or google spotted the mistake ![]()
Nothing fancy:
# Check for an interactive session
[ -z "$PS1" ] && return
# Custom Prompt
PS1="\[\033[01;32m\]\u\[\033[01;34m\] \w \$\[\033[00m\] "
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# append to the history file, don't overwrite it
shopt -s histappend
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# Less Colors for Man Pages
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;38;5;74m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[38;5;246m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[04;38;5;146m'
# 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
fiPosts [ 26 to 50 of 133 ]
CrunchBang Linux Forums » Tips, Tricks & Scripts » Post your .bashrc!
Forums powered by PunBB. Hosted by Linode.
Copyright © CrunchBang Linux.
Proudly powered by Debian GNU/Linux.
Debian is a registered trademark of Software in the Public Interest, Inc.