123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- #!/bin/bash
-
- ## hack to workaround Fedora/Red Hat bug 878428
- test -f /usr/share/git-core/contrib/completion/git-prompt.sh \
- && . /usr/share/git-core/contrib/completion/git-prompt.sh
-
- #######################################################
- ### things to do BEFORE host/user-specific settings ###
- #######################################################
-
- ### .... ###
- ### SUBZ ###
- ### '''' ###
-
- git() {
- if grep -Fwqse "$1" "$GIT_DISABLED_COMMANDS"; then
- echo "You don't want this." >&2
- return 1
- else
- command git "$@"
- fi
- }
-
- grepr() {
- local p=$1; shift
- grep --color -n --exclude-dir=".git" -e "$p" -r "$@"
- }
-
- greph() {
- history | sed 's/^ *//; s/ / /' | cut -d' ' -f2- | grep "$@"
- }
-
- gitcd() {
- cd "$(git rev-parse --show-toplevel)"
- }
-
- clsz() {
- tput clear; tput cup "$(tput lines)" 0
- }
-
- bcdiff() {
- test $# -eq 2 && diff "$@" >/dev/null && return
- bcompare "$@" &
- }
-
- vims() {
- # 2015-07-10 06:10:48.603953758 +0200 ~/TODO.todo
- local swap="$HOME/.local/share/vim/swap"
- find "$swap" -type f -print0 \
- | xargs -0 -r stat -c "%y %n" \
- | sed "
- s| $swap/| |
- s|%|/|g
- s|.swp$||
- s| $HOME| ~|
- s| \(..:..\):[^ ]* +.... | \\1 |
- " \
- | sort \
- | tac
- }
-
- xod() {
- # dump xo in a file named $1 somewhere in /tmp; echo the path
- # usage: scp $(xod useful_name.txt) eg:some/shared/place
- # instead of xo>useful_name.txt; scp useful_name.txt eg:some/shared/place; rm useful_name.txt
- local name="${1:-clipboard_dump.txt}"
- local tmp=$(mktemp -d -t "xod.XXXXXXXX")
- xclip -o > "$tmp/$name"
- echo "$tmp/$name"
- }
-
- xood() {
- # just like xod() but using xoo
- local name="${1:-clipboard_dump.txt}"
- local tmp=$(mktemp -d -t "xood.XXXXXXXX")
- xclip -selection clipboard -o > "$tmp/$name"
- echo "$tmp/$name"
- }
-
- yum_hasbin() {
- local bname
- for bname in "$@";
- do
- yum provides "*bin/$bname" \
- | grep '^.' \
- | grep -E '^[0-9a-zA-Z_:.-]+ :'
- done
- }
-
- ### .... ###
- ### BASH ###
- ### '''' ###
-
- HISTCONTROL=erasedups
- HISTIGNORE="$HISTIGNORE:ls:ll:la:cd"
- HISTIGNORE="$HISTIGNORE:git dc:git st"
- #export HISTIGNORE="$HISTIGNORE:se *:sc *"
- HISTSIZE=-1
- HISTFILESIZE=100000
- GLOBIGNORE=.:..
-
- # some more aliases
- alias cal='cal -m'
- alias cls='clear'
- alias ll='ls -lh'
- alias lla='ls -lha'
- alias open='gnome-open'
- alias diff='diff -u'
- alias dmesg='dmesg --time-format iso'
- alias pad4='sed -e "/./s/^/ /"'
- alias grep='grep --color --binary-files=without-match'
- alias sc='se --direction=encz.cz'
- alias ts='ts "%F %T"'
- alias lsblk='lsblk -o +UUID,LABEL'
- alias virsh='virsh --connect qemu:///system'
- alias xaa='xclip -o | audit2allow'
- alias xi='xclip -i'
- alias xii='xclip -selection clipboard -i'
- alias xo='xclip -o'
- alias xoo='xclip -selection clipboard -o'
-
- RV_TMP="/tmp/bash-rv"
- mkdir -p "$RV_TMP"
-
- ### ...... ###
- ### OTHERS ###
- ### '''''' ###
-
- export LC_COLLATE=C # make sort upper first
-
- export SHELLFU_PRETTY=color
- export SHELLFU_DEBUG_EXCLUDE=inigrep
-
- # make green git bash trinket even cooler
- GIT_PS1_SHOWDIRTYSTATE=true
- GIT_PS1_SHOWUNTRACKEDFILES=true
- GIT_DISABLED_COMMANDS="$HOME/.gittum/disabled-commands"
- export GIT_PAGER='less -S'
-
- # disable mounting things like SFTP to ~/.gvfs when accessed
- # via GIO (used by nautilus etc.)
- export GVFS_DISABLE_FUSE=1
-
- # disable the terrible beep sound (only for X; for tty?, blacklist pcspkr)
- [[ ${!DISPLAY[@]} ]] && xset b off
-
- # get rid of those .pyc files once and for all
- export PYTHONDONTWRITEBYTECODE=1
-
- ssh-add -l >& /dev/null || ssh-add
|