You are not logged in.

#1 2005-03-23 19:03:00

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

basrc/bashprofile

After looking at the vimrcs posted, I thought it might be interesting to share some bashrc/bash_profiles (whichever you put your customizations in -- my bash_profile just sources bashrc). I'm always interested in finding more efficient ways to use bash.

shopt -s cdspell
shopt -s extglob
shopt -s lithist
shopt -s no_empty_cmd_completion
shopt -u promptvars

alias ls='ls --color'
alias lsa='ls --color --all'
alias reboot='sudo /sbin/reboot'
alias halt='sudo /sbin/halt'
alias jedit='jedit -reuseview'
alias cdb='cd $(cat $HOME/.currentbuffer)'

source /etc/bash_completion

PS1='u:W $ '
PS1='[33[01;34m]u:[33[01;35m]W [33[01;31m]$ [33[00m]' 
PATH=$PATH:$HOME/bin
EDITOR='vim'
HISTIGNORE='&:fg:bg:ls:pwd:cd ..:cd*:jobs:ls -l:ls -a'
HISTIGNORE=${HISTIGNORE}':%1:%2:popd:pushd:'
HISTCONTROL=ignoredups
INPUTRC=~/.inputrc

CLASSPATH=$CLASSPATH:$HOME/bin/classpath/:$HOME/bin/classpath/activation.jar:$HOME/bin/classpath/mail.jar

export PATH TERMCMD EDITOR HISTIGNORE HISTCONTROL INPUTRC CLASSPATH
export DOCS=$HOME/Documents
export ENSMER=$DOCS/code/java/ensmer
export DUSTYWEB=$DOCS/websites/dusty2

#:mode=shellscript:

Also, share your bash tips and tricks... did you know that typing

<ESC>.

expands to the last typed argument? I just found this out.... maybe its something I should have known. ;-)  Also, somebody mentioned in another topic that ~n, where n is a digit from 0 to 9 allows you to access the last directory on the stack, something else I didn't know. (The stack is printend with dirs, added to with pushd, removed with popd, for those that don't know)

One thing I've noticed, I often discover new efficient ways of doing things, be it in my text editor, on the commandline, or in a program (usually new abbreviations or keyboard shortcuts, for example), and I forget to use/learn them. Any suggestions for how to get around this? I'm actually tempetd to write it all down (abbreviations, shortcuts) on a sheet of paper and look at it every few minutes to try to remember stuff...

Dusty

Offline

#2 2005-03-23 19:05:41

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: basrc/bashprofile

nothing too fancy:

# use colors with ls
alias ls='ls --color=auto -h'

# use pajman instead of pacman
alias pacman='pajman'

# my own bash prompt
PS1='[A] u:W '

# set some nice options
# allow mispelling of directories
shopt -s cdspell
# do not use comments in an interactive shell
shopt -u interactive_comments

#enable uft 8
export LANG=en_US.UTF-8
export LC_ALL=$LANG
export LESSCHARSET=utf-8

# enable scim
export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE="scim"

Offline

#3 2005-03-23 19:17:10

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: basrc/bashprofile

wow, I just discovered the "shopt" command...

Offline

#4 2005-03-23 19:22:53

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: basrc/bashprofile

you really should brows the bash manpage, there's tons of stuff you'd never expect.

Offline

#5 2005-03-23 19:28:54

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: basrc/bashprofile

hmmm while we're on the subject (not) : anyone know how to get the home key to go to the beginning of the line instead of spitting out "~" in aterm?

Offline

#6 2005-03-23 19:49:23

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Offline

#7 2005-03-23 19:52:17

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: basrc/bashprofile

For fun, here's my .inputrc...

set show-all-if-ambiguous on
set match-hidden-files off
set expand-tilde off
set print-completion-horizontally on
C-p: history-search-backward
M-,: beginning-of-line
M-.: end-of-line
M-d: backward-char
M-n: forward-char
C-M-d: backward-word
C-M-n: forward-word
M-t: previous-history
M-h: next-history
M-x: delete-char
M-k: backward-delete-char
C-e: kill-whole-line
C-M-x: kill-word
C-M-k: backward-kill-word
C-z: undo

Also, does anybody know how to get variable completion in bash without it escaping the $character?

For example, if I have the $VARIABLE var set, and I type $VAR<tab>, it will expand to $VARIABLE. Can I turn that off?

I just thought of something, maybe that's in the bash_completion package... I cannot ready ANY of those syntax files. Which sucks, because I'd like to know how to make groovyc tab complete only *.groovy files the same way javac completes *.java files. Any ideas?

Dusty

Offline

#8 2005-03-23 19:55:41

dadexter
Member
From: Dorval, QC, Canada
Registered: 2004-09-07
Posts: 274
Website

Re: basrc/bashprofile

my .bashrc

alias ls='ls --color=auto'
alias mcd='mount /mnt/cd && mc && umount /mnt/cd'
PS1='[u@h W]$ '

my .inputrc

cat: .inputrc: No such file or directory

Offline

#9 2005-03-23 20:03:24

smith
Member
From: Crescent City, CA
Registered: 2005-02-19
Posts: 77

Re: basrc/bashprofile

phrakture wrote:

hmmm while we're on the subject (not) : anyone know how to get the home key to go to the beginning of the line instead of spitting out "~" in aterm?

Your /etc/inputrc has section for aterm/rxvt.  Add this line

"e[7~": beginning-of-line

I had to ask about this back when I installed aterm.  This should really be there as a default since the keycode for the End key is there.


I have nothing to say, and I am saying it.

Offline

#10 2005-03-23 20:27:13

smith
Member
From: Crescent City, CA
Registered: 2005-02-19
Posts: 77

Re: basrc/bashprofile

Nothing fancy...

alias ls='ls --color=auto'
alias ll='ls -lh'
alias la='ls -AF'
alias df='df -h'
alias gcc-w='gcc -W -Wall -ansi -pedantic'
alias mkdir='mkdir -p'
alias more='less'
alias which='type -all'
alias ..='cd ..'

set -o noclobber
ulimit -S -c 0

shopt -u mailwarn
unset MAILCHECK

PS1='[33[36m]u[33[m]@[33[32m]h:[33[33;1m]w[33[m]$'
HISTIGNORE='ls:cd*:ll:la:on:off:clear:exit'
HISTCONTROL=ignoredups
TERM=aterm

if [ -z "$DISPLAY" ] && [ $(tty) = /dev/vc/1 ]; then
    startx -- -br
fi

I have nothing to say, and I am saying it.

Offline

#11 2005-03-23 20:40:19

dadexter
Member
From: Dorval, QC, Canada
Registered: 2004-09-07
Posts: 274
Website

Re: basrc/bashprofile

nice little PS1 value there... I think I'll use it from now on tongue

Offline

#12 2005-03-23 21:13:31

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,615
Website

Re: basrc/bashprofile

.bashrc

# .bashrc
TERM=xterm-color
alias vi='vim'
alias ls='ls --color=auto'
alias ll='ls -l'
alias date-friendly='date +"%a %b %d %I:%M%P %Z %G"'
 
if [ "$PS1" ]; then
  /usr/bin/fortune futurama
fi
  
alias ps-custom='ps ax -o "pid user ni %cpu %mem tname stat time cmd"'
 
export PS1='[33[01;31m]([33[00;37m]u@h W[33[01;31m])[33[00m]$ '

.bash_profile

. $HOME/.bashrc

wink


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#13 2005-03-23 21:37:42

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: basrc/bashprofile

alias date-friendly, that's an interesting idea. I guess I don't need it though; I get my date from my GUI...

Dusty

Offline

#14 2005-03-23 21:45:27

skoal
Member
From: Frequent Flyer Underworld
Registered: 2004-03-23
Posts: 612
Website

Re: basrc/bashprofile

The most useful feature of bash is it's history.  'grep' the .bash_history file if you don't remember, and use:

!<abbreviation>

to get a 'quicky'

example:

'!gr' will match some long funky ass cold medina grep command in .bash_history...

My .bashrc:

alias ls='ls --color=auto'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
PS1='[u@h W]$ '

Gene Simmons baby! That's right...you know what I'm talkin' 'bout Willis.  KISS...

Offline

#15 2005-03-23 21:52:12

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,615
Website

Re: basrc/bashprofile

dont forget searching backwards through history.
ctrl+r

I use that one ALOT!


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#16 2005-03-23 22:05:04

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: basrc/bashprofile

skoal wrote:

The most useful feature of bash is it's history.  'grep' the .bash_history file if you don't remember, and use:

The 'history' command also helps, and it numbers the commands so they can be used with the ! command instead of using an abbreviation.

'!gr' will match some long funky ass cold medina grep command in .bash_history...

I prefer the 'history-search-backward' functionality of input rc to this. I have this mapped to Control-P in my .inputrc above.

So if I type:

gr<Control-P>

it will expand to the command. This way I can edit it on the command line if I need to.

Dusty

Offline

#17 2005-03-23 22:09:13

skoal
Member
From: Frequent Flyer Underworld
Registered: 2004-03-23
Posts: 612
Website

Re: basrc/bashprofile

wow, we got some serious bash masters in the house.  I've only used the quickies myself.  That's good stuff to know, but it's hard to teach an old dog new tricks...

Offline

#18 2005-03-23 22:54:38

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: basrc/bashprofile

Dusty, that inputrc stuff rules... I'm adding the vim-like completion when I get hoem (but with <c-n> instead)

Offline

#19 2005-03-26 11:55:44

miqorz
Member
Registered: 2004-12-31
Posts: 475

Re: basrc/bashprofile

Mine.

###############################
# Source Global Configuration #
###############################
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

###############################
# Binary PATH                 #
###############################

PATH="$HOME/bin:/usr/local/bin:/usr/X11R6/bin:/opt/e17/bin:/opt/apps/bin:/opt/firefox:/opt/xfce43/bin:/opt/monobundle/mono/bin:$PATH"

export PATH

###############################
# Mozilla Folder              #
###############################

MOZILLA_FIVE_HOME=/opt/firefox/

export MOZILLA_FIVE_HOME

###############################
# Aliases                     #
###############################

alias startx='startx -- -dpi 72'
alias ls='ls --color'
alias mutt='mutt -y'
alias emacs='emacs -nw'


###############################
# Older Prompt Colors/Display #
###############################

LIGHT_GRAY="[33[0;37m]"
GRAY="[33[1;30m]"
LIGHT_CYAN="[33[1;36m]"
CYAN="[33[0;36m]"
LIGHT_BLUE="[33[1;34m]"
BLUE="[33[0;34m]"
ORANGE="[33[0;33m]"
RED="[33[0;31m]"
GREEN="[33[0;32m]"
LIGHT_GREEN="[33[1;32m]"
YELLOW="[33[0;33m]"
RESET="[33[0;0m]"
MAGENTA="[33[35m]"

#PS1="$RED::{$LIGHT_CYANu$GRAY@$CYANh $RED($GREENT$RED) $GRAY- $ORANGEw$RED }::n$LIGHT_GREEN.oOo. $RESET";export PS1

PS1="$RED$(date +[%l:%M]) $BLUE[$CYANw$BLUE] $ORANGE$ $RESET"

export PS1


###############################
# Set Term Title              #
###############################

case $TERM in
        xterm*|rxvt|Eterm|eterm)
                PROMPT_COMMAND='echo -ne "33]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}07"'
                ;;
        screen)
                PROMPT_COMMAND='echo -ne "33_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}33\"'
                ;;
esac

###############################
# Set File Colors             #
###############################

LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:';
export LS_COLORS


http://wiki2.archlinux.org/

Read it. Love it. Live it. Or die.

Offline

#20 2005-05-04 04:31:02

Vinny
Member
From: the fifth floor
Registered: 2005-04-25
Posts: 29

Re: basrc/bashprofile

my .bashrc

alias mv="mv -i"
alias cp="cp -i"
alias ls="ls --color=always"
alias l="ls -lh"
alias df="df -m"
alias mplyr="mplayer -fixed-vo -fs"
alias startx="startx -- -dpi 96"
alias vi=":"

eval `dircolors -b ~/.dir_colors`

export EDITOR="jed"
export PAGER="most"
export NNTPSERVER="news.<myisp>.net"
export COLORTERM=1

COLOR1="[33[0;36m]"
COLOR2="[33[0;32m]"
COLOR3="[33[0;36m]"
COLOR4="[33[0;37m]"
if [ "$UID" = "0" ];
then
## I am root
COLOR2="[33[0;31m]"
fi
PS1="$COLOR2($COLOR3u@h$COLOR2)-($COLOR1@$COLOR2 $COLOR1d$COLOR2)-($COLOR1W$COLOR2)$COLOR1n$COLOR1\$ $COLOR4"
PS2="> "
export PS1 PS2
PATH=$HOME/bin:$PATH
export PATH 

now here's the interesting part:

.bash_login

. $HOME/.bashrc
if [[ $DISPLAY == "" ]]; then
   echo -e '33[?17;0;44c'
   else true
fi 

and root's .bash_login, line 3

echo -e '33[?17;0;74c'

Offline

Board footer

Powered by FluxBB