Created
September 21, 2017 14:10
-
-
Save WaterSibilantFalling/d70b049d1bcf2a3c38daf77df33f38ff to your computer and use it in GitHub Desktop.
bashrc
This file contains 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
#!/bin/bash -x | |
# System-wide .bashrc file for interactive bash(1) shells. | |
if [[ -n "$done_bashrc" ]] ; | |
then | |
return 0 | |
fi | |
done_bashrc="bananarama" | |
shopt -s checkwinsize | |
# echo "in /etc/bash.bashrc" | |
# enable bash completion in interactive shells | |
#if [ "$PS1" -a -f /etc/bash_completion ]; then | |
# . /etc/bash_completion | |
#fi | |
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
#------ time date zone ------ | |
TZ='Pacific/Auckland'; export TZ | |
# TZ='Europe/Istanbul'; export TZ | |
# set the time with date MMDDhhmm[[CC]YY][.ss] // NB : no -s | |
# eg date 110723092008.45 | |
# Nov 7th 23:09 (11.09 pm) and 45 seconds | |
# or date +%Y%m%d -s "20081128" // NB with -s | |
# set the local time with | |
# date +%T -s "11:40:02" | |
#------- sane umask (at last) -------------- | |
# gives dirs : rwxr------ | |
# files: rw-r------ | |
umask 037 | |
# overridden for root | |
# stop the ctrl-s freeze, and ctrl-q continue | |
stty stop undef | |
stty start undef | |
#------ language, font, Local ---------- | |
source /etc/environment | |
export 'EDITOR=nvim' | |
#------ env ----------------------------- | |
# do NOT set the $TERM var here | |
export LESS="$LESS -J -Q" | |
export 'PERL_UNICODE=AS' | |
export 'PERL5OPTS=-CDAS' | |
export 'PULSE_LATENCY_MSEC=30 ' | |
export 'QT_ACCESSIBILITY=0' | |
# export 'NO_AT_BRIDGE=1' | |
#----- paths ---------------------------- | |
export PERLLIB="/usr/local/lib/site_perl/" | |
#---------- ls aliases --------------------- | |
# enable color support of ls and also add handy aliases | |
alias ll='ls -lhL -L --color=always --group-directories-first ' | |
alias la='ls -alvbHF --color=always ' | |
# alias lld='la | egrep ^d\|^l ' # replaced with one line script | |
alias lll='/bin/ls -lhL -L --group-directories-first | less' | |
alias llr='la -rt' | |
alias lsr='ls -rtL -1 --color=always ' | |
alias ls='ls --color=always --group-directories-first ' | |
# NOTE : adjusting ls (say) WILL affect earlier defined ls aliases | |
# -F : append */->@! to indicate file type | |
# -L : show what a link points to | |
# -h : human readable sizes (101M, 2.3G) | |
#alias l='ls -CF' | |
alias td='td_real 100' | |
alias td1='td_real 1' | |
alias td2='td_real 2' | |
alias td3='td_real 3' | |
alias td4='td_real 4' | |
alias td5='td_real 5' | |
# --------------- 'cdXYZ' aliases ---------- | |
# this can also be done via /etc/inputrc | |
alias cddoc='cd /usr/share/doc' | |
alias cdb='cd /home/bench' | |
alias cdn='cd /home/bench/notes' | |
alias cdw='cd /home/bench/work ' | |
alias cda='cd /home/bench/work/Active' | |
alias cdt='cd /home/temp' | |
alias cdm='cd /usbhd/music/musicLibrary' | |
alias cdlib='cd /home/library' | |
alias cdllib='cd /home/library ; ls -F' | |
alias cdlog='cd /var/log/' | |
alias cdllog='cd /var/log/; ls -al -rt ' | |
alias cdc=' cd /bench/coding/' | |
alias cdtd=' cd `mktemp -d` ' | |
# make dir and change to it | |
md () { mkdir -p "$@" && cd "$@"; } | |
# ----- Bash Directory Bookmarks ------------------------------ | |
# echo "set up apparix" | |
# --- new bookmarking, from 2015-12-17 | |
function jcd () { | |
if test "$2"; then | |
cd "$(apparix "$1" "$2" || echo .)"; | |
else | |
cd "$(apparix "$1" || echo .)"; | |
fi | |
pwd | |
} | |
function jmk () { | |
if test "$2"; then | |
apparix --add-mark "$1" "$2"; | |
elif test "$1"; then | |
apparix --add-mark "$1"; | |
else | |
apparix --add-mark; | |
fi | |
} | |
function portal () { | |
if test "$1"; then | |
apparix --add-portal "$1"; | |
else | |
apparix --add-portal; | |
fi | |
} | |
# function to generate list of completions from .apparixrc | |
function _apparix_aliases () | |
{ cur=$2 | |
dir=$3 | |
COMPREPLY=() | |
if [ "$1" == "$3" ] | |
then | |
COMPREPLY=( $( cat $HOME/.apparix{rc,expand} | \ | |
grep "j,.*$cur.*," | cut -f2 -d, ) ) | |
else | |
dir=`apparix -favour rOl $dir 2>/dev/null` || return 0 | |
eval_compreply="COMPREPLY=( $( | |
cd "$dir" | |
\ls -d *$cur* | while read r | |
do | |
[[ -d "$r" ]] && | |
[[ $r == *$cur* ]] && | |
echo \"${r// /\\ }\" | |
done | |
) )" | |
eval $eval_compreply | |
fi | |
return 0 | |
} | |
# command to register the above to expand when the 'jcd' command's args are | |
# being expanded | |
complete -F _apparix_aliases jcd | |
alias jls=' apparix ' | |
alias jrm='echo "to add again, type:" ; apparix -purge-mark ' | |
# #------------ application aliases ------------- | |
# --experimental--- man pages in nvim | |
export MANPAGER="nvim -c 'set ft=man' -" | |
# # colourized man pages | |
# # very detailed description here: | |
# # http://boredzo.org/blog/archives/2016-08-15/colorized-man-pages-understood-and-customized | |
# ---experimental--- removed | |
# best: | |
# | |
# man() { | |
# env \ | |
# LESS_TERMCAP_mb=$(printf "\e[1;31m") \ | |
# LESS_TERMCAP_md=$(printf "\e[1;31m") \ | |
# LESS_TERMCAP_me=$(printf "\e[0m") \ | |
# LESS_TERMCAP_se=$(printf "\e[0m") \ | |
# LESS_TERMCAP_so=$'\e[1;40;92m' \ | |
# LESS_TERMCAP_ue=$(printf "\e[0m") \ | |
# LESS_TERMCAP_us=$(printf "\e[1;32m") \ | |
# man "$@" | |
# } | |
# LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ | |
# same, diff method: | |
# alias man="LESS_TERMCAP_mb=$'\x1B[1;31m' \ | |
# LESS_TERMCAP_md=$'\x1B[1;31m' \ | |
# LESS_TERMCAP_me=$'\x1B[0m' \ | |
# LESS_TERMCAP_se=$'\x1B[0m' \ | |
# LESS_TERMCAP_so=$'\x1B[1;40;92m' \ | |
# LESS_TERMCAP_ue=$'\x1B[0m' \ | |
# LESS_TERMCAP_us=$'\x1B[1;32m' \ | |
# man" | |
# 9 is red | |
# 2 is green | |
# export LESS_TERMCAP_mb=$(tput bold; tput setaf 2) # green | |
# export LESS_TERMCAP_md=$(tput bold; tput setaf 9) # cyan | |
# export LESS_TERMCAP_me=$(tput sgr0) | |
# export LESS_TERMCAP_so=$(tput bold; tput setaf 2; tput setab 0) # yellow on black | |
# export LESS_TERMCAP_se=$(tput rmso; tput sgr0) | |
# export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 7) # white | |
# export LESS_TERMCAP_ue=$(tput rmul; tput sgr0) | |
# export LESS_TERMCAP_mr=$(tput rev) | |
# export LESS_TERMCAP_mh=$(tput dim) | |
# export LESS_TERMCAP_ZN=$(tput ssubm) | |
# export LESS_TERMCAP_ZV=$(tput rsubm) | |
# export LESS_TERMCAP_ZO=$(tput ssupm) | |
# export LESS_TERMCAP_ZW=$(tput rsupm) | |
# man() { | |
# env \ | |
# LESS_TERMCAP_md=$'\e[1;36m' \ | |
# LESS_TERMCAP_me=$'\e[0m' \ | |
# LESS_TERMCAP_se=$'\e[0m' \ | |
# LESS_TERMCAP_so=$'\e[1;40;92m' \ | |
# LESS_TERMCAP_ue=$'\e[0m' \ | |
# LESS_TERMCAP_us=$'\e[1;32m' \ | |
# man "$@" | |
# } | |
# really, these should all call named scripts | |
alias p='ps axf' | |
alias tsl='tail -n 50 -f /var/log/syslog ' | |
alias vi='nvim ' | |
alias sshq='scrot -cd 5 -m -q 100 ' # optional filename is written here | |
alias sslq='scrot -cd 5 -m -q 50 ' # dumps to auto file in curr dir | |
alias sss=' scrot -q 100 -s ' # select the window (to dump) title bar | |
alias bdump=' bible -f Gen1:1-Rev22:21 ' | |
alias ntdump=' bible -f Mat1:1-rev22:21 ' | |
alias otdump=' bible -f Gen1:1-Mal4:6 ' | |
#alias mutt='cd ~/mail/muttBaseDir ; mutt; cd - ' | |
alias nobu=' dontBuThisDir.pl -d $PWD -f ' | |
alias portlist='netstat -tulanp' | |
alias mi=' audtool --current-song-filename ' | |
alias grammerbook=' zathura /home/library/writing/grammer/books/englishGrammar_aUniversityCourse.pdf & ' | |
alias perldb='PERL5LIB="/usr/local/bin/KomodoPerlDebugging" PERL5DB="BEGIN {require q($PERL5LIB/perl5db.pl)}" PERLDB_OPTS="RemotePort=localhost:9000" perl -d ' | |
# --- office suite | |
alias ooc=' /usr/lib/libreoffice/program/scalc ' | |
alias oow=' /usr/lib/libreoffice/program/swriter ' | |
alias oo=' /usr/lib/libreoffice/program/soffice.bin ' | |
# --- | |
alias gtklp=' echo; echo "spool is /var/spool/cups"; echo; gtklp' | |
alias bleachbit='df -h; bleachbit; echo "=== after ==="; df -h' | |
# --- make vim the man page viewer | |
#alias man=' /usr/local/bin/sdm_man ' | |
function vigp () { | |
vi $(grep -Rl "$@" ./*) | |
} | |
# usage: vigp 'some string' | |
# will search for it down the dir heirachy | |
#------ force options onto commands ----------- | |
alias rm='rm -I ' | |
alias mv='mv -i ' | |
#alias locate='mlocate -i --wholename -A ' | |
# locate is now a wrapper in /usr/local/bin | |
alias locatex='mlocate -i --wholename -A --regexp ' | |
# -i : ignore case | |
# --wholename:match the searchstring against anypart of the filename | |
# -A :'and' all of the search words are required | |
alias cp='cp --no-preserve=mode,ownership' | |
alias ifup='ifup --force ' | |
alias bc='bc -l ' | |
alias xfontsel='xfontsel -print ' | |
alias unrar='nice -n 20 unrar ' | |
export LESSCHARSET=utf-8 | |
alias grep='grep --color=always -d skip ' | |
alias egrep='egrep --color=always -d skip ' | |
alias fgrep='fgrep --color=always -d skip ' | |
alias tail=' tail -n 30 ' | |
alias mysql=' mysql --local-infile ' | |
alias df=' df -h ' | |
alias di=' di -s m -f SM1fb' | |
alias tmux='tmux -2 ' | |
alias sudo='PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH sudo ' | |
alias startx='startx -- vt7 ' | |
alias gliv='gliv --recursive=off ' | |
#------ use aliases to make commands -------------- | |
alias X_bashcolors='for first in {0..47}; do for second in {0..8}; do printf " \\e[%u;%um%s[%0.2u;%0.2um\e[0m " $first $second "\e" $first $second; done; echo; done' | |
#----- path ---- | |
# /usr/local/bin BEFORE other drives so can replace what is in /bin/, /usr/bin | |
PATH='/usr/local/bin:/usr/bin:/bin' | |
# ----------- set prompt ---------------------- | |
# echo "set the prompt" | |
PS1="\[\033[35m\]\D{%I:%M %a %d-%b-%y} \[\033[32m\][\w] \n\[\033[1;33m\]\u > \[\033[0m\]" | |
# --- enable programmable completion features (you don't need to enable | |
# this, if it's already enabled in /etc/bash.bashrc). | |
if [ -f /etc/bash_completion ]; then | |
. /etc/bash_completion | |
fi | |
#--- history | |
HISTCONTROL=ignorespace | |
# some, or all of these should be - and are - in /etc/inputrc | |
bind '"\e[A"':history-search-backward | |
bind '"\e[B"':history-search-forward | |
# --- for vi editing mode, ";;" maps to <ESC> to change to command mode | |
# bind '";;":"\x1B"' | |
# took this out tracking down colours problems 2016-09-08 | |
# source $HOME/.dynamic-colors/completions/dynamic-colors.bash | |
# ------- colours ---------------------------------------------------------- | |
# # to purifu the colours? | |
# if [ "$TERM" = "linux" ] || [ "$TERM" = "fbterm" ]; then | |
# echo -en "\e]P0000000" | |
# echo -en "\e]P85D5D5D" | |
# echo -en "\e]P1C75646" | |
# echo -en "\e]P9E09690" | |
# echo -en "\e]P28EB338" | |
# echo -en "\e]PACDEE69" | |
# echo -en "\e]P3D0B03C" | |
# echo -en "\e]PBFFE377" | |
# echo -en "\e]P472B3CC" | |
# echo -en "\e]PC9CD9F0" | |
# echo -en "\e]P5C9A0D1" | |
# echo -en "\e]PDFBB1F9" | |
# echo -en "\e]P6218693" | |
# echo -en "\e]PE77DFD8" | |
# echo -en "\e]P7B0B0B0" | |
# echo -en "\e]PFF7F7F7" | |
# clear # bring us back to default input colours | |
# fi | |
eval `dircolors -b /etc/dircolors/dircolors_rainbow` | |
# --- copying colours from Xresources | |
# echo "Copying colours from Xresources" | |
if [ "$TERM" = "linux" ] || [ "$TERM" = "fbterm" ]; then | |
_SEDCMD='s/.*\*color\([0-9]\{1,\}\).*#\([0-9a-fA-F]\{6\}\).*/\1 \2/p' | |
for i in $(sed -n "$_SEDCMD" $HOME/.Xresources | awk '$1 < 16 {printf "\\e]P%X%s", $1, $2}'); do | |
echo -en "$i" | |
done | |
clear | |
fi | |
# --- force the font in the terminal | |
#echo "setting the terminal font" | |
if [ "$TERM" == "linux" ] || [ "$TERM" == "fbterm" ] | |
then | |
setfont Lat15-Terminus12x6 | |
fi | |
# NOTE: this *SHOULD* be set by /etc/default/console-setup, but at 2017-01-31 this was not working | |
# so forcing it here | |
# --- use fbterm ---- | |
# | |
# why? Can I get anything (256 colours) from fbterm? ... not so far. | |
# | |
# run fbterm if on a virtual console | |
# if [ -n "$FBTERM" ] | |
# then | |
# export TERM="fbterm" | |
# fi | |
# echo "about to run fbterm" | |
# if [ "$TERM" == "linux" ] | |
# then | |
# export aa="bb" | |
# fbterm | |
# fi | |
# echo "finished /etc/bash.bashrc" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment