-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_functions
54 lines (46 loc) · 1.44 KB
/
dot_functions
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
function share_history {
# remember everything from every terminal on the machine while having that history accessible from every terminal
# shout-out to https://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
}
#### functions ####
function git_clone {
local -r repos="$1"
pushd ~/Work/github.com
git clone git@github.com:${repos} ${repos}
pushd ${repos}
}
function venv {
local -r env="${PYTHON_ENVS}/${1}/bin/activate"
if [[ -f ${env} ]]; then
source "${env}"
else
>&2 echo "error: '$1' is not a valid virtual environment"
fi
}
function github {
firefox https://github.com/$1
}
function tgz_compress {
tar cvf - $1 | gzip > $2
}
function mkd {
mkdir -p $1 && cd $_
}
# get IP address for the given container and network
function get_container_network_ip {
local -r container_name="${1}"
local -r network_name="${2}"
docker inspect "${container_name}" | jq -r ".[0].NetworkSettings.Networks.\"${network_name}\".IPAddress"
}
# Colored man pages
man() {
env LESS_TERMCAP_mb=$'\E[01;31m' \
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
LESS_TERMCAP_me=$'\E[0m' \
LESS_TERMCAP_se=$'\E[0m' \
LESS_TERMCAP_so=$'\E[38;5;246m' \
LESS_TERMCAP_ue=$'\E[0m' \
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
man "$@"
}