-
Notifications
You must be signed in to change notification settings - Fork 8
/
.bashrc
executable file
·128 lines (100 loc) · 3.62 KB
/
.bashrc
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
export EDITOR="vim"
export MANPAGER="less -X"
export LC_ALL="en_US.UTF-8"
export LANG="en_US"
export HOMEBREW_CASK_OPTS="--appdir=/Applications"
eval "$(/opt/homebrew/bin/brew shellenv)"
PATH=$PATH:/Applications/MacVim.app/Contents/bin
PATH=$PATH:~/development/dotfiles/bin
PATH="/usr/local/opt/[email protected]/bin:$PATH"
source "$(brew --prefix)/etc/bash_completion.d/git-completion.bash"
eval "$(starship init bash)"
function aws_sso_hours {
AWS_SSO_EXPIRES_AT=`ls --color=never -1tr ~/.aws/sso/cache/*.json | grep -v boto | tail -n 1 | xargs cat | jq '.expiresAt' | sed -e 's/\"//g'`
AWS_SSO_EPOCH=`date -ju -f "%FT%TZ" "$AWS_SSO_EXPIRES_AT" '+%s'`
AWS_SSO_HOURS=`expr $(expr $AWS_SSO_EPOCH - $(date '+%s')) / 3600`
if [ $AWS_SSO_HOURS -lt "0" ]; then
echo -ne "⛈️"
else
echo -ne "🌤️"
fi
}
export -f aws_sso_hours
function docker_compose_helper() {
service=$1
shift
action=$@
dcyml="${HOME}/development/${service}/docker-compose.yml"
if [ ! -f "$dcyml" ]; then
echo "Can't find docker-compose.yml file for ${service} -- $dcyml"
return
fi
docker-compose -f $dcyml $action
}
function parse_jwt() {
local token=$1
local payload=`echo $token | cut -d '.' -f 2`
local len="${#payload}"
local mod=$((len % 4))
if [[ $mod -gt 0 ]]; then
local pad=$((4 - mod))
local padding=`echo '======' | cut -c 1,$pad`
local payload="${payload}${padding}"
fi
echo "$payload"
echo $payload | base64 --decode | jq '.'
}
function copy_current_branch_name() {
git symbolic-ref --short HEAD | tr -d '\n' | pbcopy
}
function docker_prompt_for_bash() {
local container=`docker ps --format '{{.ID}} {{.Names}}' | fzf | cut -f 1 -d ' '`
if [ ! -z $container ]; then
docker exec -it $container bash
fi
}
function set_title() {
echo -n -e "\033]0;${1}\007\c"
}
# z beats cd most of the time. `brew install z`
zpath="$(brew --prefix)/etc/profile.d/z.sh"
[ -s $zpath ] && source $zpath
## Aliases
alias ll="ls -l"
alias json_pretty="python -m json.tool"
alias godev="cd ~/development"
alias dc="docker_compose_helper"
alias jwt="parse_jwt"
alias title="set_title"
alias prov="~/development/bin/odreadprov.sh"
alias unugly="npm run --prefix ~/development/wishbone-utilities/unugly unugly"
alias getbuid="/Users/dheindel/development/wishbone-utilities/getbuid/getbuid.rb"
alias getlib="/Users/dheindel/development/wishbone-utilities/getbuid/getlib.rb"
alias findlib="/Users/dheindel/development/wishbone-utilities/getbuid/findlib.rb"
alias gb="copy_current_branch_name"
alias jkb="open https://jenkins-read.svc.overdrive.com/job/wishbone_server_deploy/build?delay=0sec"
alias jka="open https://jenkins-read.svc.overdrive.com/job/wishbone_js_upload_to_asset_server/build?delay=0sec"
alias myip="ipconfig getifaddr en0"
alias dsh="docker_prompt_for_bash"
alias wishbone="open http://wishbone.dev.dv.io"
alias alpha="open https://soraalpha.com"
alias beta="open https://sorabeta.com"
alias charlie="open https://soraapp.com"
alias headers="httpstat"
export HTTPSTAT_SAVE_BODY=false
###
# time to upgrade `ls`
# use coreutils `ls` if possible…
hash gls >/dev/null 2>&1 || alias gls="ls"
# always use color, even when piping (to awk,grep,etc)
if gls --color > /dev/null 2>&1; then colorflag="--color"; else colorflag="-G"; fi;
export CLICOLOR_FORCE=1
# ls options: A = include hidden (but not . or ..), F = put `/` after folders, h = byte unit suffixes
alias ls='gls -Fh ${colorflag}'
alias lsd='ls -l | grep "^d"' # only directories
# `la` defined in .functions
###
# here's LS_COLORS
# github.com/trapd00r/LS_COLORS
command -v gdircolors >/dev/null 2>&1 || alias gdircolors="dircolors"
eval "$(gdircolors -b ~/.dircolors)"