Author Topic: .bashrc what its it good for then!?  (Read 1042 times)

Offline Hootiegibbon

  • Hero Member
  • *****
  • Posts: 4151
.bashrc what its it good for then!?
« on: January 04, 2012, 12:10:42 PM »

Ok Archie inspired me to post this, its  a good diversion form other things.

bash rc sets out a ;lot of environmental stuff can be used to set up user created command alias's and even set up command-chain shortcuts

I though as we "advanced" users - or tinkerers/messers  as I refer to my self as like this stuff I though I ould shre the content of mine - some is not actually used or is just me learning bits and pieces

Code: [Select]

#!/bin/bash
#bashrc 'borrowed' snippits



# Colors:
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'




export BROWSER='/usr/bin/xxxterm -n'
export DE=xfce
export IPLAYER_OUTDIR="/home/jason/Videos/"

#alias vte="vte --reverse -f Tamsyn -A -D"
alias xanim=mplayer
#alias xterm=sakura
alias screen='screen -R'
alias ycal="cal -y | xmessage -file - &"
 

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi


####


extract()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.tar.Z) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.jar) unzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*) echo "'$1' cannot be extracted." ;;
esac
else
echo "'$1' is not a file."
fi
}

##

       
# History Options
# ###############

# Don't put duplicate lines in the history.
 export HISTCONTROL="ignoredups"
 shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000



localnet ()
{
/sbin/ifconfig | awk /'inet addr/ {print $2}'
echo ""
/sbin/ifconfig | awk /'Bcast/ {print $3}'
echo ""
}

######
alias colours="./.colours.sh"
alias colors="./.colours.sh"

#####

#PS1='\[\e[0;34m\]┌──[\[\e[0;32m\]\u\[\e[0;31m\]@\[\e[0;35m\]\h\[\e[0;34m\]]──\[\e[0;34m\][\[\e[0;32m\]\w\[\e[0;34m\]] \n└── \[\e[0;34m\]'



#### PSFUN
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*|screen*)
    PS1="┌──[\A]──[\u@\h]──[\w]\n└─> "
    ;;
*)
    ;;
esac

#### PHUN PHUN PHUN this has no real purpose but is PHUN!

wha ()
{
clear
echo -e "${blue}";figlet "RAW Edition";
#echo -ne "${red}Today is:\t\t${cyan}" `date`; echo ""
#echo -e "${red}Kernel Information: \t${cyan}" `uname -smr`
echo -ne "${cyan}";infobash -v;echo ""
echo -e "${grey}"; cal -3; echo -e "${nc}"
}

function gmail() {
    curl -u [i][u]username[/u][/i] --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title><summary>(.*)<\/summary>.*?<name>(.*?)<\/name>.*$/\n$3\n\t$1\n\t$2/'
}

So what interesting stuff do you have in your .bashrc (remove any password stuff)

Jase


I am Hootiegibbon, undisputed champion fo the typo

My .dotfiles

Offline AndrzejL

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 12798
  • RLU #490933
    • Wordpress On The Wardrobe...
Re: .bashrc what its it good for then!?
« Reply #1 on: January 04, 2012, 12:18:57 PM »
I like my .bashrc nice and clean. I tried power prompt in the past but I always returned to the bare config. It's just neat...

Regards.

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: .bashrc what its it good for then!?
« Reply #2 on: January 04, 2012, 01:53:24 PM »
the only things I have added to my .bashrc are two PATH additions and one env var:

I have a few commands/utilities built from myself, located on a separate filesystem, so are available when dual-booting avoiding duplicates of the commands (mostly shell scripts):

Quote
if ! echo $PATH | grep -q "/u/lbin"
then
        PATH=$PATH:/u/lbin ; export PATH
fi

Another addition is a "relative path" (path that doesn't begin with '/' ),  I usually build my own software and the resulting executables will be located into the "pc10" directory.

Quote
if ! echo $PATH | grep -q "pc10"
then
        PATH=$PATH:pc10 ; export PATH
fi

I can build my project1 in /u/project1/pc10/excutable1 while working in /u/project1, the command "executable1" will be found in PATH
and my project2 in /u/projetc2/pc10/executable2 while working in /u/project2, same as above the "executable2" will be found in PATH

This allow for an "easy" launch of the applications while they are "work in progress", without any type of installation.
The surrounding "if" are needed to avoid multiple inclusion of the same directory in PATH.

Finally I have an env vars, it was needed to edit comments before to commit some additions to a project located on a SVN server.
Quote
SVN_EDITOR=vim ; export SVN_EDITOR

nothing too much fancy!  :D

AS



Offline djohnston

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6227
  • I don't do Windows
Re: .bashrc what its it good for then!?
« Reply #3 on: January 04, 2012, 05:49:00 PM »
No aliases and nothing special. Just a customized prompt I copied from another PCLinuxOS forum user.

PS1="\n\[\033[1;35m\]\$(/bin/date +%a\ %b\ %e\ %r\ %Z\ %Y)\n\[\033[0;36m\]\w\n\[\033[1;32m\]\u@\h: \[\033[1;34m\] \[\033[1;36m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') items \[\033[1;33m\]\$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\033[0m\] -> \[\033[0m\]"  #shows the date and time, what dir you are presently in, how many items there are and total size, all in multi-colors

Bare metal                           VBox
AMD Athlon 7750 Dual-Core    Single core
4GiB RAM                              1GiB RAM
nVidia GeForce FX 5200          64MB video
LXDE 32bit                            KDE 64bit

Registered Linux User #416378

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Re: .bashrc what its it good for then!?
« Reply #4 on: January 04, 2012, 08:40:06 PM »
I though as we "advanced" users - or tinkerers/messers  as I refer to my self as like this stuff I though I ould shre the content of mine - some is not actually used or is just me learning bits and pieces

So what interesting stuff do you have in your .bashrc (remove any password stuff)

Jase

tinkerers/messers sound like something out of a Disney movie. ;D

But I like it.

The only lines I added or was automagically added were:

Code: [Select]
# Personal modification to the command prompt
if [ "$PS1" ]; then
  PS1="\[\033[01;39m\]\u@\H \[\033[01;31m\]\W \[\033[01;39m\]> \[\033[00m\]"
fi

 #setup XIM environment, need not if use SCIM as gtk-immodules
 export GTK_IM_MODULE=xim
 export QT_IM_MODULE=xim
 export XMODIFIERS="@im=fcitx"

source ~/.aliaser/aliases.sh
/usr/bin/aliaser
/usr/bin/aliaser show-tips


# Added by autojump install.sh
source /etc/profile.d/autojump.bash

But you gonna fall off your chair if you see my .bash_aliases and ./aliaser/aliases.sh.

AutoKey is also nice as it supplements my hotkeys on KDE's systemsettings but I am unable to update to the latest as the builds although successful are not doing what they are supposed to do so I'm stuck with 0.71.3 and latest is already 0.81.4.

Anyway, good thread, Jasse and thanks for the mention.  ;)
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2843
    • other projects...
Re: .bashrc what its it good for then!?
« Reply #5 on: January 05, 2012, 03:36:52 AM »
FullMonty users already have fif = find in file (from maik3531) included:

Code: [Select]
fif() {
find . -type f -print | xargs grep --color=auto "$1" 2> /dev/null
}

fif will search all files down the current directory for the existence of a given search string, i.e., in a konsole in your $HOME enter:
Code: [Select]
fif Desktop or for searching for strings with space enter:
Code: [Select]
fif "Desktop Entry"Obviously fif-searches are case sensitive.

A great tool which helped me a lot!  ;)
 

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15847
  • LXDE! Coffee, Bacon and Cheesecake!
Re: .bashrc what its it good for then!?
« Reply #6 on: January 05, 2012, 03:50:58 AM »
Archie an inspiration. :o Wow! Impressive! :D