-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash.conf
78 lines (68 loc) · 2.4 KB
/
bash.conf
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
# vim: filetype=sh
# tmux auto completion
source ~/.bash_addons/tmux
# tmux save shell history for each pane
source ~/.bash_addons/tmux-save-history.sh
# git info prompt
GIT_PROMPT_ONLY_IN_REPO=1
GIT_PROMPT_SHOW_UPSTREAM=1
GIT_PROMPT_THEME_FILE=~/.bash_addons/git-prompt-colors.sh
source ~/.bash_addons/bash-git-prompt/gitprompt.sh
# update session variables from tmux
# based on https://babushk.in/posts/renew-environment-tmux.html
if [ -n "$TMUX" ]; then
function tmux_refresh {
eval $(tmux showenv -s)
}
#declare -- PROMPT_COMMAND="${PROPMP_COMMAND};refresh"
else
function tmux_refresh {
true
}
fi
# git aliases
alias glh='git log $(git rev-parse --abbrev-ref --symbolic-full-name @{u}) ^HEAD'
# man colors
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'
# Change bindings
# https://stackoverflow.com/questions/1030182/how-do-i-change-bash-history-completion-to-complete-whats-already-on-the-line
# ~/.bashrc
if [[ $- == *i* ]]
then
# up/down arrows
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
# page up/down
bind '"\e[5~": previous-history'
bind '"\e[6~": next-history'
fi
# set tmux title on ssh
if [ -n "$TMUX" ]; then
__ssh_get_hostname() {
# Note: Options without parameter were hardcoded,
# in order to distinguish an option's parameter from the destination.
#
# s/[[:space:]]*\(\( | spaces before options
# \(-[46AaCfGgKkMNnqsTtVvXxYy]\)\| | option without parameter
# \(-[^[:space:]]* | option
# \([[:space:]]\+[^[:space:]]*\)\?\)\) | parameter
# [[:space:]]*\)* | spaces between options
# [[:space:]]\+ | spaces before destination
# \([^-][^[:space:]]*\) | destination
# .* | command
# /\6/ | replace with destination
echo "$@" | sed 's/[[:space:]]*\(\(\(-[46AaCfGgKkMNnqsTtVvXxYy]\)\|\(-[^[:space:]]*\([[:space:]]\+[^[:space:]]*\)\?\)\)[[:space:]]*\)*[[:space:]]\+\([^-][^[:space:]]*\).*/\6/'
}
ssh() {
tmux rename-window "$(__ssh_get_hostname $*)"
command ssh "$@"
tmux setw automatic-rename "on"
}
fi
alias wsl_sync_time='sudo hwclock -s'