summaryrefslogtreecommitdiffstats
path: root/.bashrc
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2014-02-20 19:53:33 +0100
committerJan Pokorný <jpokorny@redhat.com>2014-02-20 19:53:33 +0100
commitc741d1e3b5f14ac1f5b6e71305e82ee39569b413 (patch)
treea734e628ae262c6d988de1ecce6b212b3b597a88 /.bashrc
parenta40ce854e831530f37b656419bc5c7f55a88fb17 (diff)
downloaddotfiles-c741d1e3b5f14ac1f5b6e71305e82ee39569b413.tar.gz
dotfiles-c741d1e3b5f14ac1f5b6e71305e82ee39569b413.tar.xz
dotfiles-c741d1e3b5f14ac1f5b6e71305e82ee39569b413.zip
Bash config: auto-pagination trick for selected cmds (rpm, ...)
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to '.bashrc')
-rw-r--r--.bashrc27
1 files changed, 26 insertions, 1 deletions
diff --git a/.bashrc b/.bashrc
index 1491d82..9b5045d 100644
--- a/.bashrc
+++ b/.bashrc
@@ -26,7 +26,9 @@ _linkalias () {
linkalias () { alias "$1=_linkalias $2"; }
# Source the other common definitions
-for f in /etc/bashrc ~/.bashrc-dotfiles ~/.bashrc-fedora ~/.bashrc-work ~/.bashrc-xml ~/.bashrc-priv; do
+_bashconfs="~/.bashrc-dotfiles ~/.bashrc-fedora ~/.bashrc-work ~/.bashrc-xml ~/.bashrc-priv ~/.bashrc-preexec"
+for f in ${_bashconfs}; do
+ f=${f/#~/$HOME}
[ -f "${f}" ] && source "${f}" || :
done
@@ -117,3 +119,26 @@ img-qr () {
|| { input=$(</dev/stdin); title+="$(echo "${input}" | head -n1)"; }
xloadimage -fit -shrink -title "${title}" <(qrencode -m0 -s40 -o- "${input}" )
}
+
+# prexec stuff
+
+_preexec_flag=0
+# idea is simple: auto-paginate output of selected commads that cannot do it
+# on their own
+# XXX: hacky, not exactly sure why this (and so far only this) works :)
+preexec() {
+ local cmd=${1%% *}
+ #test ${_preexec_flag} -eq 0 && test ${BASH_SUBSHELL} -eq 0 \
+ # || { _preexec_flag=0; return 0; }
+ test ${BASH_SUBSHELL} -eq 0 || { _preexec_flag=0; return 0; }
+ case "$1" in
+ rpm\ *|yum\ list\ *)
+ _preexec_flag=1
+ ${1} <&- 2>&1 | ${PAGER}
+ trap "_preexec_flag=0; trap - RETURN;" RETURN
+ return 2
+ ;;
+ esac
+}
+
+preexec_install