Created
August 23, 2017 20:11
-
-
Save peteristhegreat/ebb1d0948b92cae8d1e6aec18ec04c04 to your computer and use it in GitHub Desktop.
Another .bashrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#PS4='+ $(date "+%s.%N")\011 ' | |
#exec 3>&2 2>/tmp/bashstart.$$.log | |
#set -x | |
# User specific aliases and functions | |
case "$HOST" in | |
myhost[123479]|theirhost[34]) | |
export VAR123=/path1/; | |
*) | |
export VAR123=/path2/; | |
esac | |
# export LESS='-R' | |
alias lf='ls -F --color=tty' | |
alias la='ls -aF --color=tty' | |
alias ll='ls -lF --color=tty' | |
alias emacs='emacs -nw' | |
alias vim='vim -o' | |
alias e='vim' | |
alias c='clear' | |
alias rmail='emacs -f rmail' | |
alias send='emacs -f mail' | |
alias xterm='xterm -g 90x40 -fn 10x20 -ls -sb -sl 2000' | |
alias gopath='_(){ cd ${MYFOLDER}/src/checkpt_$1; }; _' | |
#set completion-ignore-case on | |
#if [ `alias -p | grep 'alias cd' | wc -l` -ge 1 ]; then | |
# unalias cd | |
#fi | |
# if [ -z "$BASHRC_LOADED" ]; then | |
# # Colorize output of stderr and stdout | |
# exec 9>&2 | |
# exec 8> >( | |
# while IFS='' read -r line || [ -n "$line" ]; do | |
# echo -e "\033[31m${line}\033[0m" | |
# done | |
# ) | |
# function undirect(){ exec 2>&9; } | |
# function redirect(){ exec 2>&8; } | |
# trap "redirect;" DEBUG | |
# PROMPT_COMMAND='undirect;' | |
# # end colorize output | |
# export BASHRC_LOADED="1" | |
# fi | |
make_uniq () { | |
make 2> >(uniq | highlight 'green' '-o' 1>&2) | |
} | |
cdl () { | |
cd "$(dirname "$(readlink "$1")")"; | |
} | |
case "$-" in | |
*i*) # This shell is interactive ;; | |
# http://linux.101hacks.com/ps1-examples/prompt-color-using-tput/ | |
bold=$(tput bold) | |
white=$(tput setaf 7) | |
# blue=$(tput setaf 4) | |
# magenta=$(tput setaf 5) | |
# cyan=$(tput setaf 6) # \e[36m | |
reset=$(tput sgr0) # \e[0m # RESET | |
export PS1='\[$bold\]\u\[$reset\]@\h/\[$white\]\W\[$reset\]> ' | |
stty -ixon #enable Ctrl+S for use with bash history commands | |
# Ctrl-S normally suspends the terminal, and Ctrl-Q Resumes it | |
;; | |
*) # This shell is not interactive ;; | |
;; | |
esac | |
#export PS1="\u@\h/\W> " | |
export PATH="${PATH}:$HOME/usr/bin:$HOME/usr/local/bin:$HOME/.local/bin" | |
export PERL5LIB="${PERL5LIB}:$HOME/usr/lib/perl5:$HOME/usr/share/perl5:$HOME/usr/lib/perl5/vendor_perl/5.14.2" | |
export PYTHONPATH="${PYTHONPATH}:$HOME/usr/lib/python2.6:$HOME/usr/lib/python2.6/site-packages/" | |
export QTDIR="/path/to/local/qt/qt4.8" | |
#export QTDIR="/usr/lib/qt4" | |
export EDITOR="vim" | |
export LPDEST=printer.lan | |
export PRINTER=printer.lan | |
export SYSPRINTER=printer.lan | |
export GREP_COLOR='00;38;5;157' | |
# alias xterm='xterm -ls -sb -rightbar -bg rgb:00/2b/36 -fg rgb:83/94/96 -g 90x40+0+0 -fa "DejaVu Sans Mono" -fn 12x24 -ls -sb -sl 9000' | |
alias xterm="/usr/bin/xterm -ls -sb -rightbar -bg rgb:00/2b/36 -fg rgb:83/94/96 -g 90x40+0+0 -fa 'DejaVu Sans Mono' -fn 12x24 -ls -sb -sl 9000" | |
#export QT_STYLE_OVERRIDE="GTK+" | |
enable_inotify() { | |
export LD_LIBRARY_PATH="$HOME/usr/lib" | |
} | |
enable_tmux() { | |
export LD_LIBRARY_PATH="$HOME/usr/lib" | |
} | |
enable_shellcheck() { | |
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${MYFOLDER}/var/shellcheck/usr/lib" | |
export PATH="${PATH}:${MYFOLDER}/var/shellcheck/usr/bin" | |
} | |
enable_qmake() { | |
# export LD_LIBRARY_PATH="${HOME}/usr/lib:${GCC_4_8}/lib" | |
# export CPATH="${HOME}/usr/include" | |
# export LD_LIBRARY_PATH="${QTDIR}/lib" | |
# export CPLUS_INCLUDE_PATH="${QTDIR}/include" | |
} | |
enable_prefix(){ | |
export PKG_CONFIG_PATH="${HOME}/usr/lib/pkgconfig:${HOME}/usr/share/pkgconfig:${GCC_4_8}/lib/pkgconfig" | |
} | |
resume(){ | |
if [ -a ./Session.vim ] ; then | |
vim -S Session.vim | |
else | |
vim -p *.c *.h | |
fi | |
} | |
# alias untar-all='for i in *.tar.gz ; do tar -zxvf $i ; done' | |
# alias untar='tar -xvf --checkpoint=.1000 --totals=USR1' | |
alias gitdiff='git difftool HEAD^ HEAD' | |
# alias errcho='>&2 echo' | |
echoerr() { cat <<< "$@" 1>&2; } | |
alias restartbash='. ~/.bashrc' | |
alias editbash='vim ~/.bashrc' | |
# newxterm() { unset BASHRC_LOADED; xterm &; } | |
# echoerr 'Red Text Test <== should be red' | |
alias svn=${HOME}/usr/bin/svn-color.py | |
alias restartxterm='xrdb -merge ~/.Xdefaults' | |
alias last-commited-changes='git difftool HEAD^ HEAD' | |
alias cdp='cd -P' | |
alias greph='history | grep' | |
#export TERM=xterm-256color | |
alias cd..='cd ..' | |
alias cd-='cd -' | |
#test $(alias cd) -eq 1 && unalias cd | |
unalias cd >/dev/null 2>/dev/null | |
######################### | |
# Bash History Persistence | |
export HISTCONTROL=ignoredups:erasedups # no duplicate entries | |
export HISTSIZE=100000 # big big history | |
export HISTFILESIZE=100000 # big big history | |
shopt -s histappend # append to history, don't overwrite it | |
if [[ $PROMPT_COMMAND == *"history"* ]]; then | |
: | |
else | |
# Save and reload the history after each command finishes | |
#export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" | |
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r" | |
fi | |
# | |
######################## | |
function makeredtext() | |
{ | |
# colorize output, error turns red on command line | |
exec 9>&2 | |
exec 8> >( | |
while IFS='' read -r line || [ -n "$line" ]; do | |
echo -e "\033[31m${line}\033[0m" | |
done | |
) | |
function redirect(){ exec 2>&8; } | |
function undirect(){ exec 2>&9; } | |
#if [[ $PROMPT_COMMAND == *"undirect"* ]]; then | |
# : | |
#else | |
# OLD_PROMPT_COMMAND="${PROMPT_COMMAND}" | |
# trap - DEBUG | |
trap "redirect;" DEBUG | |
PROMPT_COMMAND="${PROMPT_COMMAND}"$'\n'"undirect;"; #PROMPT_COMMAND='\nundirect;' | |
#fi | |
#function toggleredtext() | |
#{ | |
# if [[ $PROMPT_COMMAND == *"undirect"* ]]; then | |
# echo "removing red text" | |
# PROMPT_COMMAND="${OLD_PROMPT_COMMAND}" | |
# trap - DEBUG | |
# else | |
# echo "adding red text" | |
# trap "redirect;" DEBUG | |
# PROMPT_COMMAND="${PROMPT_COMMAND}"$'\n'"undirect;"; | |
# fi | |
#} | |
} | |
# end colorize output ############################# | |
export HOSTALIASES=~/.hosts | |
function vim_inst(){ | |
dir=$(basename $PWD) | |
#dir=${dir:5} | |
vim $dir.svn $dir.inst | |
} | |
function clear_inst(){ | |
dir=$(basename $PWD) | |
#dir=${dir:5} | |
> $dir.svn | |
> $dir.inst | |
} | |
function xclip_inst(){ | |
dir=$(basename $PWD) | |
#dir=${dir:5} | |
xclip -o >> $dir.svn | |
xclip -o >> $dir.inst | |
} | |
export NO_COMMENTS='-G'"'"'(^[^\*# ])|(^#\w)|(^\s+[^\*#])'"'"'' | |
alias greps='grep --color=auto --exclude-dir=\".svn\" -nR' | |
export GREP_OPTIONS="--color" | |
export MANPATH="$HOME/usr/local/man:$HOME/usr/man:$HOME/usr/share/man/overrides:$HOME/usr/share/man/en:$HOME/usr/share/man:$HOME/usr/local/share/man:$MANPATH" | |
alias vncviewer='~/usr/bin/vncviewer' | |
alias qgit='qgit &>/dev/null' | |
alias w='w_with_colors' | |
#!/usr/bin/bash | |
function highlight() { | |
declare -A fg_color_map | |
fg_color_map[black]=30 | |
fg_color_map[red]=31 | |
fg_color_map[green]=32 | |
fg_color_map[yellow]=33 | |
fg_color_map[blue]=34 | |
fg_color_map[magenta]=35 | |
fg_color_map[cyan]=36 | |
fg_c=$(echo -e "\e[1;${fg_color_map[$1]}m") | |
c_rs=$'\e[0m' | |
sed -u s"/$2/$fg_c\0$c_rs/g" | |
} | |
function svns() | |
{ | |
temp=$(pwd) | |
for D in `find . -maxdepth 1 -mindepth 1 -type d -not -path '*/\.*'`;do | |
echo $D | |
cd $D | |
svn status -u | |
cd $temp | |
done | |
} | |
function find_src() | |
{ | |
(cd ${GRP_SRC_FOLDER}; grep -s -r -I --exclude-dir={.svn,useless_folder,old} "$1" .; ) | |
} | |
function find_configs() | |
{ | |
function finish() | |
{ | |
export GREP_OPTIONS="$GREP_OPTIONS_OLD" | |
} | |
GREP_OPTIONS_OLD="$GREP_OPTIONS"; | |
export GREP_OPTIONS=''; | |
trap finish EXIT; | |
grep -s -h -r -I --exclude-dir={.svn,data_file} "$1" /path/to/config/files/root | sed 's/\s\+/\t/g' | sed 's/^#\s*//' | sort | uniq | highlight 'green' "$1" | |
} | |
function pretty() | |
{ | |
tmp=$(git show --pretty="" --name-only HEAD) | |
out='' | |
while read -r line; do | |
prefix="A" | |
if [[ $line == *"folder_a"* ]] ; then | |
prefix="B" | |
elif [[ $line == *"folder_b"* ]] ; then | |
prefix="C" | |
elif [[ $line == *"folder_c"* ]] ; then | |
prefix="D" | |
fi | |
new=$(echo "$prefix $(echo $line | sed 's:\(.*\)/:\1 :')") | |
if [ -n "$out" ]; then | |
out="$out\n$new" | |
else | |
out="$new" | |
fi | |
done <<< "$tmp" | |
echo -e "$out" | xclip | |
} | |
function realpath() | |
{ | |
f=$@ | |
if [ -d "$f" ]; then | |
base="" | |
dir="$f" | |
else | |
if [ ! -a "$f" ]; then | |
f=$(type -p "$f") | |
fi | |
base="/$(basename "$f")" | |
dir=$(dirname "$f") | |
fi | |
dir=$(cd "$dir" && /bin/pwd) | |
echo "$dir$base" | |
} | |
#export XKB_DEFAULT_RULES="evdev" | |
#export XKB_DEFAULT_MODEL="pc105" | |
#export XKB_DEFAULT_LAYOUT="lv,us" | |
#export XKB_DEFAULT_VARIANT="apostrophe" | |
#export XKB_DEFAULT_OPTIONS="apostrophe" | |
alias fortune="fortune /path/to/fortune" | |
#function qtcreator () | |
#{ | |
# /path/to/qt/qt-creator_2.5/bin/qtcreator.sh $@ >/dev/null 2>&1 & | |
#} | |
function sqldiff2() | |
{ | |
diffuse <(sqlite3 "$1" .dump) <(sqlite3 "$2" .dump) & | |
} | |
alias karm="ktimetracker >/dev/null 2>&1 &" | |
if [ -f ".otherrc" ]; then | |
. .otherrc | |
fi | |
alias svnu='for i in */; do (cd "$i"; svn update); done' | |
#alias get_screenshots="(cd /path/to/get_screenshots; get_screenshots.bash ) &" | |
alias merge_files="cat *.txt.* | column -t | sort | uniq | sed -e 's/#.*$//' -e '/^$/d' > \$(basename \$PWD).txt; cat *.md.* | column -t | sort | uniq | sed -e 's/#.*$//' -e '/^$/d' > \$(basename \$PWD).md" | |
#set +x | |
#exec 2>&3 3>&- | |
# Use bash-completion, if available | |
#[[ $PS1 && -f $HOME/share/bash-completion/bash_completion ]] && \ | |
# . $HOME/share/bash-completion/bash_completion | |
enable_qmake | |
function resume_qt_gui() | |
{ | |
pro=$(grep -oP '(?<=RecentProjects\\FileNames=)(.*)' $HOME/.config/Nokia/QtCreator.ini | sed -e 's:, :\n:g' | grep -v "qt4.8/examples" | head -n1) | |
qtcreator "$pro" | |
} | |
function resume_qt() | |
{ | |
pro=$(grep -oP '(?<=RecentProjects\\FileNames=)(.*)' $HOME/.config/Nokia/QtCreator.ini | sed -e 's:, :\n:g' | grep -v "qt4.8/examples" | head -n1) | |
cd $(dirname "$pro") | |
vim . | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment