annotate .bashrc @ 115:2bcf31c52c14

include sh-script
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Tue, 15 Jun 2021 16:58:03 +0000
parents bcea0410143c
children 9de06ae73372
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
1 # .bashrc
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
2
112
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 83
diff changeset
3 export G=${HOME}/gentoo
0
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
4 # Uncomment the following line if you don't like systemctl's auto-paging feature:
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
5 # export SYSTEMD_PAGER=
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
6
83
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
7 if [ $SHELL = "/bin/bash" ]
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
8 then
112
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 83
diff changeset
9 # Vanilla Cirrus login
83
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
10 # Source global definitions
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
11 if [ -f /etc/bashrc ]; then
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
12 . /etc/bashrc
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
13 fi
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
14
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
15 if [ "$PS1" ]; then
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
16 PS1='\[\033[1m\]\h\[\033[0m\]<\!>: '
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
17 echo "Vanilla bashrc" 1>&2
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
18 # don't put duplicate lines or lines starting with space in the history.
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
19 # See bash(1) for more options
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
20 # export HISTCONTROL=ignoreboth [readonly on Cirrus :-[
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
21
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
22 # append to the history file, don't overwrite it
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
23 shopt -s histappend
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
24
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
25 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
26 # export HISTSIZE=3000 [readonly on Cirrus :-[
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
27 export HISTFILESIZE=6000
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
28 fi
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
29
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
30 module load gcc # assumed by Prefix
112
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 83
diff changeset
31 module load gnu-parallel
83
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
32
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
33 export PYTHONPATH=$HOME/lib/python3.6/site-packages
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
34
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
35 PATH="/lustre/home/dc007/hst/lib/perl5/bin${PATH:+:${PATH}}"; export PATH;
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
36 PERL5LIB="/lustre/home/dc007/hst/lib/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
37 PERL_LOCAL_LIB_ROOT="/lustre/home/dc007/hst/lib/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
38 PERL_MB_OPT="--install_base \"/lustre/home/dc007/hst/lib/perl5\""; export PERL_MB_OPT;
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
39 PERL_MM_OPT="INSTALL_BASE=/lustre/home/dc007/hst/lib/perl5"; export PERL_MM_OPT;
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
40
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
41 export ANT_HOME=$HOME/src/apache-ant-1.10.7
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
42 export MAVEN_HOME=$HOME/src/apache-maven-3.6.3
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
43 export JAVA_HOME=$HOME/lib/openjdk-8u252-b09
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
44 export PATH=${PATH}:${ANT_HOME}/bin:${MAVEN_HOME}/bin
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
45
112
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 83
diff changeset
46 EDITOR=emacs
83
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
47 else
112
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 83
diff changeset
48 # gentoo
83
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
49 if [ "$PS1" ]; then
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
50 echo "~/.bashrc inside gentoo" 1>&2
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
51 PS1='\[\e[1;32m\]\h\[\e[0m\]<\!>: '
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
52 # Source some global definitions?
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
53
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
54 # These are readonly under Cirrus, so repeated here where they work1
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
55 export HISTCONTROL=ignoreboth
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
56 export HISTSIZE=3000
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
57 export HISTFILESIZE=6000
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
58 shopt -s histappend
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
59
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
60 if [ "$DISPLAY" ]
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
61 then
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
62 xrdb $HOME/.Xresources
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
63 fi
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
64 fi
112
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 83
diff changeset
65 EDITOR=xemacs
83
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
66 fi
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
67
0
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
68 # User specific aliases and functions
83
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
69 #module add gnu-parallel
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
70 #export N1=rli4n35
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
71 #export N2=rli6n35
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
72 #export NN="$N1 $N2"
0
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
73
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
74 # Tools
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
75 function lss() {
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
76 /bin/ls -l "$@" | sort -nr -k 5,5
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
77 }
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
78
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
79 function sus() {
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
80 sort "$@" | uniq -c | sort -k1nr,1
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
81 }
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
82
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
83 function tot ()
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
84 {
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
85 awk '{sum+=$1} END {printf "%u\n",sum}'
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
86 }
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
87
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
88 btot ()
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
89 {
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
90 python3 -c 'import sys
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
91 n=0
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
92 for l in sys.stdin:
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
93 n+=int(l)
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
94 print(n)
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
95 '
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
96 }
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
97
112
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 83
diff changeset
98 function uz () { $G/usr/bin/igzip -dc "$@" ; }
83
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
99
0
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
100 function typecat ()
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
101 {
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
102 tt=$(type $1)
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
103 case $tt in
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
104 *\ is\ hashed\ *) cat $(echo $tt | cut -f 4 -d ' ' | tr -d '()') ;;
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
105 *\ is\ /*) cat $(echo $tt | cut -f 3 -d ' ' | tr -d '()') ;;
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
106 *) type $1 ;;
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
107 esac
65a56c0d1c1f bolting the barn door...
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
108 }
83
8fb11e337e23 environment improvements
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 61
diff changeset
109 #export HISTSIZE=3000
61
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 20
diff changeset
110
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 20
diff changeset
111 PATH=$PATH:$HOME/.local/bin:$HOME/bin
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 20
diff changeset
112
112
Henry S. Thompson <ht@inf.ed.ac.uk>
parents: 83
diff changeset
113 export PATH EDITOR PS1 G