Skip to content

Commit e21cb75

Browse files
committed
bash: Update config, add functions and profile.sh
1 parent 65a9643 commit e21cb75

File tree

3 files changed

+97
-43
lines changed

3 files changed

+97
-43
lines changed

bash/config

+44-43
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,60 @@
1-
# rvm-prompt supplied with rvm is very slow, here's my faster alternative:
2-
function __fast_rvm_ps1() {
3-
rubybin=$(command -v ruby)
4-
if [[ "${rubybin/rvm/}" != "$rubybin" ]] ; then
5-
withoutprefix="${rubybin/*rubies\//}"
6-
justversion="${withoutprefix/\/*}"
7-
echo "$justversion "
8-
fi
9-
}
1+
# Expand ** in filenames to recursive match
2+
shopt -s globstar
3+
4+
export EDITOR=/usr/bin/vim
105

116
# export GIT_PS1_SHOWUPSTREAM=auto
127
# export GIT_PS1_SHOWUPSTREAM=verbose
138
# export GIT_PS1_SHOWUNTRACKEDFILES=1
149
# export GIT_PS1_SHOWSTASHSTATE=1
15-
# export GIT_PS1_SHOWDIRTYSTATE=1
16-
. /usr/local/git/contrib/completion/git-completion.bash
10+
export GIT_PS1_SHOWDIRTYSTATE=1
11+
if [ -f /usr/lib/git-core/git-sh-prompt ] ; then
12+
. /usr/lib/git-core/git-sh-prompt
13+
elif [ -f /usr/share/git-core/contrib/completion/git-prompt.sh ] ; then
14+
. /usr/share/git-core/contrib/completion/git-prompt.sh
15+
fi
1716

1817
# Set the prompt
1918
#export PS1='\[\e[0;32m\]\u@\h \[\e[1;32m\]\w\[\e[0;32m\] \$\[\e[0m\] '
20-
export PS1='$(__fast_rvm_ps1)\u@\h \w$(__git_ps1) \$ '
19+
if [[ "$(type -t __git_ps1)" == 'function' ]] ; then
20+
# export PS1='\u@\h \w$(__git_ps1) \$ '
21+
PROMPT_COMMAND='__git_ps1 "${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]" " \$ "'
22+
#else
23+
# export PS1='\u@\h \w \$ '
24+
fi
25+
26+
if [ -f /usr/local/bin/kubectl ] ; then
27+
. <(kubectl completion bash)
28+
fi
2129

2230
# ls colors on macos
2331
export CLICOLOR=1
2432

25-
# turn on grep colors
26-
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
27-
2833
# turn on timestamps in bash history
2934
export HISTTIMEFORMAT='%F %T '
3035

31-
if [ -f /Applications/MacVim.app/Contents/MacOS/Vim ] ; then
32-
export EDITOR=/Applications/MacVim.app/Contents/MacOS/Vim
33-
fi
36+
# don't add command-line to history if it starts with 3 spaces
37+
export HISTIGNORE=" *"
38+
39+
# Colours for less(1). This is taken from a standard /etc/profile.d/less.sh on
40+
# a modern Linux.
41+
export LESS_TERMCAP_mb=$'\E[01;31m'
42+
export LESS_TERMCAP_md=$'\E[01;38;5;208m'
43+
export LESS_TERMCAP_me=$'\E[0m'
44+
export LESS_TERMCAP_se=$'\E[0m'
45+
export LESS_TERMCAP_ue=$'\E[0m'
46+
export LESS_TERMCAP_us=$'\E[04;38;5;111m'
47+
48+
alias ls='ls --color'
49+
alias ll='ls -la'
50+
alias grep='grep --color=auto'
3451

35-
function sumcolumn () {
36-
awk -f <(echo '
37-
# Sum up numerical values by column (white-space separated)
38-
#
39-
# Usage: $0 [file ...]
40-
#
41-
# stern, 1999-2005
42-
# from http://stackoverflow.com/questions/295781/shortest-command-to-calculate-the-sum-of-a-column-of-output-on-unix
43-
44-
{
45-
for(i = 1; i <= NF; ++i) {
46-
scale = 1
47-
if ($i ~ /[kK]$/) { scale = 1000 }
48-
if ($i ~ /[mM]$/) { scale = 1000*1000 }
49-
if ($i ~ /[gG]$/) { scale = 1000*1000*1000 }
50-
col[i] += scale * $i;
51-
}
52-
if (NF > maxnf) maxnf = NF;
53-
}
54-
55-
END {
56-
for(i = 1; i <= maxnf; ++i) { printf " %.10g", col[i] }
57-
print "";
58-
}') $*
59-
}
52+
. ~/dotfiles/bash/functions
53+
54+
# Go
55+
export PATH=$PATH:/usr/local/go/bin
56+
57+
if [ -x "${HOME}/.local/bin/wsl-ssh-agent-relay" ] ; then
58+
${HOME}/.local/bin/wsl-ssh-agent-relay start
59+
export SSH_AUTH_SOCK=${HOME}/.ssh/wsl-ssh-agent.sock
60+
fi

bash/functions

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
json() {
2+
python -mjson.tool $@
3+
}
4+
5+
# Convert photos of whiteboard to readable images
6+
whiteboard() {
7+
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
8+
}
9+
10+
count_files() {
11+
for f in "$@" ; do
12+
echo "$f" $(find "$f" -type f | wc -l)
13+
done
14+
}
15+
16+
download() {
17+
curl --fail -L -O "$1"
18+
}
19+
20+
tmux-new() {
21+
TERM=putty tmux -2 new -s dubek
22+
}
23+
24+
tmux-resume() {
25+
SHELL=/bin/bash exec tmux -2 new -A -s dubek
26+
}
27+
28+
dsf() {
29+
diff-so-fancy | less -RFXS
30+
}
31+
32+
fix-ssh() {
33+
eval $(tmux show-env -s |grep '^SSH_')
34+
}

bash/profile.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# This is included from ~/.profile
3+
#
4+
5+
export PATH=$PATH:/usr/local/go/bin
6+
7+
case "$TERM" in
8+
screen|tmux)
9+
;;
10+
*)
11+
printf '\n\033[01;32m'
12+
echo "################################"
13+
echo "# #"
14+
echo "# Consider running tmux-resume #"
15+
echo "# #"
16+
echo "################################"
17+
printf '\033[00m\n'
18+
;;
19+
esac

0 commit comments

Comments
 (0)