-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbss.linux.bash
More file actions
100 lines (94 loc) · 2.61 KB
/
bss.linux.bash
File metadata and controls
100 lines (94 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
echo Setting up BASH for $(uname -s) ...
echo : HOST: $HOSTNAME
echo : BASH: $BASH
# Common setups
# xset -r
set autolist
set show-all-if-ambiguous on
export vbell=off
export TERM=xterm-256color
export EDITOR=vim
# Prompt
SHORTPROMPT=0
export B_PATHREPLACEPATTERN='\/home\/$USER/\~'
# btitle '$HOSTNAME : $PWD'
btitle '$PWD'
if [ $SHORTPROMPT -eq 1 ]; then
export B_PATHREPLACEPATTERN='*\//.../'
fi
function recolorprompt {
local promptcolor=${1:-green}
if [[ -n "$SGE_O_HOST" || -n "$LSB_HOSTS" ]]; then
if [[ $HOSTNAME == *odc* ]]; then
bprompt bold+$promptcolor 'pwd' '>>'
else
bprompt bold+$promptcolor 'pwd' '>>'
fi
else
bprompt $promptcolor 'pwd' '>'
# bprompt $promptcolor '\[$(tput bold)\]pwd' '>'
fi
}
recolorprompt
if [ -n "$CTX_REMOTE_DISPLAY" ]; then
export DISPLAY=$CTX_REMOTE_DISPLAY
fi
if [[ -r ~/.Xresources && -n "$DISPLAY" ]]; then
xrdb -merge ~/.Xresources
fi
function recolor {
local type=$1
local fgs=("#4444ee" "#444444" "#6020cc")
local bgs=("#ffffbf" "#eeeeee" "#ddffff")
local i=$(shuf -i0-$((${#fgs[@]}-1)) -n1)
local j=$(shuf -i0-$((${#bgs[@]}-1)) -n1)
recolorprompt
if [ -z "$type" ]; then
bxtermcolor fg=${fgs[$i]} bg=${bgs[$j]}
elif [ $type == fg ]; then
bxtermcolor fg=${fgs[$i]}
elif [ $type == bg ]; then
bxtermcolor bg=${bgs[$j]}
elif [ $type == reverse ]; then
recolorprompt white
bxtermcolor bg=${fgs[$i]} fg=${bgs[$j]}
fi
}
# GitHub setup for password save
# create file ~/.git-credentials with content:
# https://<username>:<classic-personal-access-token>@github.com
# Get classic personal access token from Settings->Developer Settngs
git config --global credential.helper store
# git config --global credential.helper cache
# To sync: git pull, to commit: git add; git commit -m ".."; git push
# Common aliases
balias ll 'ls -al' "list alternative"
balias cdt 'cd ~/scratch' "go to scratch area"
function search_replace {
local search=${1?$FUNCNAME: error: specify search}
local replace=${2?$FUNCNAME: error: specify replace}
grep -RiIl "$search" | xargs sed -i "s/$search/$replace/g"
}
bhelp search_replace "search and replace"
function broken_links {
local path=${1:-.}
local delete=${2:-no}
if [ $delete == delete ]; then
delete=-delete
else
delete=
fi
find $path -xtype l $delete -print
}
function f {
if [ "$#" -eq 1 ]; then
root=.
ext=$1
follow=-follow
else
root=$1
ext=$2
follow=
fi
find $root/ -name "*.$ext" $follow
}