summaryrefslogtreecommitdiffstats
path: root/.bashrc
blob: cf737c7f1008fb3f0d206aed09523bca09f69d2a (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
# .bashrc

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

# User specific aliases and functions

shopt -s histappend
HISTSIZE=5000
HISTCONTROL=ignoreboth

# subshell to avoid triggering DEBUG. (src: http://stuff.lhunath.com/.bashrc)
PROMPT_COMMAND='(history -a)'
PS1='\[\033[01;34m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ '

alias mc='LESS="-RSX" mc'

# see https://bugzilla.redhat.com/show_bug.cgi?id=852197
pkgdep() {
	TMPFILE=$(mktemp rpqXXXX);
	repoquery --tree-requires -- "$1" \
 	  | grep -v -eglibc -e$(rpm -q python) -e$(rpm -q python-libs) \
	  | sed -n '$q;/^.*bash/bend;p;d;:end n;bend' \
	  | tac >${TMPFILE}
	while sed -i \
 	  's/^\([ ]*\)|\([^|\\]*\)/\1 \2/;t;1bbad;:ok $q0;n;bok;:bad $q1;n;bbad' \
	  ${TMPFILE}; do : ; done
	cat -- ${TMPFILE} | tac
	rm -f -- ${TMPFILE}
}

# something like "fedpkg prep"
rpmbuild-patch() {
        local filter=cat verbose=
        if [ "$1" = "-v" ]; then
                verbose="--define \"_default_patch_flags $(rpm --eval %{_default_patch_flags}) --verbose\""
                shift
        fi
	[ -t 1 ] && filter='sed s|^\(Hunk.*\)|\x1b[1;31m\1\x1b[0m|'
	{ LC=C eval rpmbuild -bp --nodeps \
	  --define \"_builddir $(pwd)\" \
	  --define \"_sourcedir $(pwd)\" \
	  ${verbose} \"${@}\"
	} | ${filter}
}

# Jim Meyring's take on "display the programs with W and X memory"
# http://lists.fedoraproject.org/pipermail/devel/2013-April/181747.html
sec-wx-mem() {
	grep -lE '^[0-9a-f-]+ .wx' /proc/*/maps 2>/dev/null \
	  | perl -ne 'm!^(/proc/(\d+))/.*! and printf qq(%5d %s\n), $2, `cat $1/cmdline`' \
	  | tr '\0' ' '
}

cdup() {
	local up="."
	for i in $(seq 1 $1); do up+="/.."; done
	cd "${up}" 2>/dev/null || :
	unset up
}