gfxmonk / app-customisations

A motley collection of modifications and customations I've made to various apps.

This URL has Read+Write access

app-customisations / bash_essential.sh
100755 97 lines (81 sloc) 2.149 kb
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
#!/bin/sh
# essential functionality in a single file; for easy deployment to new boxes
# usage:
# curl <location> > /tmp/bashrc && . /tmp/bashrc
 
# common and obvious aliases
alias ll='ls -l'
alias la='ls -la'
alias lt='ls -lrt'
 
alias grep='egrep --color'
alias less='less -R' # raw character support (ie colours)
 
# other names for things
alias ad='pushd' # "add dir"
alias sd='popd' # "subtract dir"
alias pbcopy='xsel -ib' # that's what it's called on a mac ;)
alias pbpaste='xsel -ob'
 
# additional functionality
alias cwd='echo -n `pwd` | xsel -ib' # copy working dir to clipboard
 
# shorthand
alias ff='firefox'
alias open='gnome-open'
alias tm='gedit' # nothing like it, but I habitually use "tm" on linux
 
 
function xmm {
   xmodmap -e "$@" >/dev/null 2>&1
}
# i hate capslock with a passion... uncomment the below line if you agree
#xmm 'remove Lock = Caps_Lock'; xmm 'keysym Caps_Lock = Control_L'; xmm 'add Control = Control_L'
 
# ----------------------------
# functions
# ----------------------------
 
function color-diff
{
# inline ruby? CLASSY!
ruby -e '
$stdin.each do |line|
puts( if line =~ /^\+(.*)$/
"\e[32m#{$&}\e[0m"
elsif line =~ /^-(.*)$/
"\e[31m#{$&}\e[0m"
elsif line =~ /^@(.*)$/
"\e[36m#{$&}\e[0m"
elsif line =~ /^[^ \t](.*)$/
"\e[36m#{$&}\e[0m"
else
line
end
)
end
'
}
 
# make subversion diff almost as awesome as git's:
function svn-diff
{
svn diff $@ | color-diff
}
 
alias giff='git diff --color'
 
# alias 'g' to git. If no args supplied, do "git status"
function g
{
if [ "$#" = '0' ]; then
git status
else
git "$@"
fi
}
 
# colours
export RED=`tput setaf 1`
export GREEN=`tput setaf 2`
export YELLOW=`tput setaf 3`
export BLUE=`tput setaf 4`
export MAGENTA=`tput setaf 5`
export CYAN=`tput setaf 6`
export WHITE=`tput setaf 7`
export LIGHT=`tput setaf 9`
export GREY=`tput setaf 0`
# ooh! pretty colours :D
export PS1='\n\[$GREY\][\T] \[$YELLOW\]\u\[$GREY\]@\[$RED\]\h \[$BLUE\]\w/\[$GREEN\] \$\[$LIGHT\] '
 
# cd to the dir containing "file"
function cdbase {
d=`dirname "$1"`
cd "$d"
}