summaryrefslogtreecommitdiffstats
path: root/bashrc
blob: faf31f6d890214b1469c5a2a612ccfcd2702d784 (plain)
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
#!/bin/bash
#
# .bashrc for non-login shells
#
# Set environment variables
export EDITOR='vim'
export CVS_RSH='ssh'
if [ -x /opt/mozilla/bin/firefox ]; then
	export BROWSER='/opt/mozilla/bin/firefox'
else
	export BROWSER='/usr/bin/links'
fi

# Various shell options
#case-insensitive filename globbing
shopt -s nocaseglob
#ignore small errors in cd
shopt -s cdspell
#no duplicates in history
export HISTCONTROL=erasedups:ignorespace
export HISTSIZE=1000

# Enable bash completion in interactive shells
if [ -f /etc/bash_completion ]; then
	source /etc/bash_completion
fi

# Custom Prompt
function bash_prompt {
	local BLUE="\[\e[1;34m\]"
	local RED="\[\e[1;31m\]"
	local GREEN="\[\e[0;32m\]"
	local NONE="\[\e[0;0m\]"

	if [ $TERM != "linux" ]; then
		local TITLEBAR="\[\e]0;\w\a\]";
	else
		local TITLEBAR="";
	fi

	export PS1="$TITLEBAR\n$RED\u$NONE@$BLUE\h $GREEN\w$NONE\n\$ "
}
bash_prompt; unset -f bash_prompt

if [ -x /usr/bin/pacman ]; then
	# pacman aliases
	alias pac='pacman'
	alias pacQ='pacman -Q'
	alias pacQs='pacman -Qs'
	alias pacQi='pacman -Qi'
	alias pacQm='pacman -Qm'
	alias pacS='sudo pacman -S'
	alias pacSy='sudo pacman -Sy'
	alias pacSyu='sudo pacman -Syu'
	alias pacSs='/usr/bin/pacsearch'
	alias pacSi='pacman -Si'
	alias pacU='sudo pacman -U'
	alias pacR='sudo pacman -R'
	alias pacRc='sudo pacman -Rc'
	alias pacRs='sudo pacman -Rs'
	alias pacO='sudo pacman-optimize'

	# helpful makepkg shortcuts
	alias makepkgclean='rm -r src/ pkg/ *~'
fi

# sanitize - set file/directory owner and permissions to normal values (644/755)
# Usage: sanitize <file>
sanitize() {
	chmod -R u=rwX,go=rX "$@"
	chown -R ${USER}.users "$@"
}

# psfind - shortcut for grepping a process name
# Usage: psfind <process name>
psfind() {
	ps -ef | egrep "PID|$@"
}

# rmbackups - remove all *~ files recursively in directory
rmbackups() {
	find -iname '*~' -exec rm -v {} \;
}

# Useful aliases
alias ls='ls --color=auto'
alias ll='ls -lh'
alias la='ls -A'
alias lla='ls -lAh'
alias lr='ls -R'
alias c='clear'
alias r='reset'

# Common misspellings
alias pdw='pwd'
alias mroe='more'
alias csv='cvs'

# source the local config
[ -f ~/.bashrclocal ] && source ~/.bashrclocal