• Forum
  • Lounge
  • post your .bashrc, or whichever preferre

 
post your .bashrc, or whichever preferred shell.

I'm curious what people put in their .bashrc I have a couple little extra bits I usually put in. Spam up up and AWAY!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Start .bashrc
# G.Campton
##############################
#
##############################
# Source global definitions
##############################

if [ -f /etc/bashrc ]; then
        . /etc/bashrc 
fi
##############################
## SHELL OPTIONS
##############################
# umask is set to ensure that newly created files
# and directories are only writable by the owner,
# but reading and executing by anyone. (chmod 755)
# umask 022 
##############################

# Use case-insensitive filename globbing
 shopt -s nocaseglob

# Make bash append rather than overwrite the history on disk
 shopt -s histappend

# When changing directory small typos can be ignored by bash
# for example, cd /vr/lgo/apaache would find /var/log/apache
 shopt -s cdspell

# Completion options
# ##################
# These completion tuning parameters change the default behavior of bash_completion:

# Define to access remotely checked-out files over passwordless ssh for CVS
# COMP_CVS_REMOTE=1

# Define to avoid stripping description in --option=description of './configure --help'
 COMP_CONFIGURE_HINTS=1

# Define to avoid flattening internal contents of tar files
 COMP_TAR_INTERNAL_PATHS=1

# If this shell is interactive, turn on programmable completion enhancements.
# Any completions you add in ~/.bash_completion are sourced last.
# case $- in
#   *i*) [[ -f /etc/bash_completion ]] && . /etc/bash_completion ;;
# esac

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

# Don't put duplicate lines in the history.
 export HISTCONTROL="ignoredups"

# Whenever displaying the prompt, write the previous line to disk
 export PROMPT_COMMAND="history -a"

# Aliases
# #######

# Some example alias instructions
# If these are enabled they will be used instead of any instructions
# they may mask.  For example, alias rm='rm -i' will mask the rm
# application.  To override the alias instruction use a \ before, ie
# \rm will call the real rm not the alias.

# Interactive operation...
 alias rm='rm -v'
 alias cp='cp -v'
 alias mv='mv -v'
 alias ls='pwd; ls -alhF --color=auto'

# Misc :)
 alias whence='type -a'                        # where, of a sort
 alias which='type -a'
 alias man='man -a'

# Print out some path variables.
alias path='echo -e ${PATH//:/\\n}'
alias libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'

# Some shortcuts for different directory listings  ( if you like remembering list calls )
# alias ls='ls -hF --color=tty'                 # classify files in colour
# alias dir='ls --color=auto --format=vertical'
# alias vdir='ls --color=auto --format=long'
# alias ll='ls -l'                              # long list
# alias la='ls -A'                              # all but . and ..
# alias l='ls -CF'                              #


##############################
## FUNCTION DEFINITIONS
##############################
# Some example functions
function settitle() { echo -ne "\e]2;$@\a\e]1;$@\a"; }

# move filenames to lowercase
function lowercase() 
{
    for file ; do
        filename=${file##*/}
        case "$filename" in
        */*) dirname==${file%/*} ;;
        *) dirname=.;;
        esac
        nf=$(echo $filename | tr A-Z a-z)
        newname="${dirname}/${nf}"
        if [ "$nf" != "$filename" ]; then
            mv "$file" "$newname"
            echo "lowercase: $file --> $newname"
        else
            echo "lowercase: $file not changed."
        fi
    done
}

# Swap 2 filenames around, if they exist
function swap()  
{               
    local TMPFILE=tmp.$$ 

    [ $# -ne 2 ] && echo "swap: 2 arguments needed" && return 1
    [ ! -e $1 ] && echo "swap: $1 does not exist" && return 1
    [ ! -e $2 ] && echo "swap: $2 does not exist" && return 1

    mv -v "$1" $TMPFILE 
    mv -v "$2" "$1"
    mv -v $TMPFILE "$2"
	echo "Done: $1 & $2 switched filenames!!!"
}

# Extract Program.
function extract()      
{
     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
}


# Local Variables:
# mode:shell-script
# sh-shell:bash
# [End of file] ~/.bashrc: */
Last edited on
I'm too lazy to change mine. All I've done is customized the prompt to have colours :)
Well it's very possible to port most console small C apps over to bash and use as functions.
I might do a translation of your code to bash just for the heck of it, I haven't done any in months so I should do something before I forget it all.
Heh heh heh, here you go.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
@echo off
d:
cd \
set path=d:\bin;%PATH%
set dircmd=/ogn
set LS_OPTIONS=-bhACp --streams
doskey >nul
doskey cp=copy $*
doskey lesss=less -S $*
doskey deltree=rd /s/q $*
doskey vi=notepad $*
doskey dird=dir /ad /d $*
doskey python=C:\PROGRA~1\Python25\python.exe $*
doskey pythonw=C:\PROGRA~1\Python25\pythonw.exe $*
title Prompt
echo on

Anything else is in either the D:\bin directory or in the existing Windows PATH.

I keep a number of batch files in D:\bin that make programs usable on demand. For example:

    gcc.bat
1
2
@set PATH=C:\PROGRA~1\MinGW\bin;%PATH%
@gcc %*

I also tend to use Marko Bozikovic's Console program.
http://sourceforge.net/projects/console/

As for Linux, I tried to update my Kubuntu and the update hosed my system. I need to reinstall, but all I ever do to .profile is just make a bunch of little aliases that makes stuff easy to type.

That and some tweaks to /etc/fstab and to grub (for my own bg image) and to the system startup scripts (to make pure-text consoles available).
For windows, I just added C:\tools\bin (mingw and cygwin install folder) to my Path.
yea same, C:\cygwin\bin and C:\cygwin\usr\bin and C:\cygwin\home\Garratt\bin to windows environment.

So those are batch scripts Duoas? never done any batch scripting... looks easy enough.
I suppose it's not necessary to do up a bash version of small apps like that as you can just throw them in the bin folder and they still exec anywhere, but I like doing it because I can make them very portable with the 1 .bashrc file. just turning them into functions within my profile.
Last edited on
It's not exactly a .bashrc (mine's virtually the defualt one, with the additional condition that when it's a login shell and on TTY1 it executes startx (actually, gnome-session, which implies startx anyway)) but I created these two scripts to help with loop device mounting; 'cause before I kept getting it wrong and I couldn't free the loop devices.

/usr/bin/mountloop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

LOOPDEV_FILE=/tmp/loopdev

if [[ $# < 2 ]]; then
    echo -e "Usage: $0 <file> <mount point>\n"
    exit
fi

LOOPDEV=`losetup -f` # Get the first free loop device

echo "$LOOPDEV" >$LOOPDEV_FILE # So that umountloop can find which
                               # device to delete

losetup $LOOPDEV $1 # Loop the file on the loop device
mount $LOOPDEV $2   # Mount the device

exit 0


/usr/bin/umountloop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh

LOOPDEV_FILE=/tmp/loopdev

if [[ ! -e $LOOPDEV_FILE]]; then
    echo -e "Error: no loop device descriptor file found at $LOOPDEV_FILE"
    exit
fi

read LOOPDEV <$LOOPDEV_FILE

umount $LOOPDEV
losetup -d $LOOPDEV

rm $LOOPDEV_FILE
exit 0
Topic archived. No new replies allowed.