-
Notifications
You must be signed in to change notification settings - Fork 1
/
.helpers
61 lines (50 loc) · 1.62 KB
/
.helpers
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
# vhosts
alias hosts='sudo vim /etc/hosts'
alias vhosts='sudo vim /etc/apache2/extra/httpd-vhosts.conf'
#copy working directory
alias cwd='pwd | tr -d "\r\n" | pbcopy'
# copy file interactive
alias cp='cp -i'
# move file interactive
alias mv='mv -i'
# untar
alias untar='tar xvf'
# Call from a local repo to open the repository on github/bitbucket in browser
function repo() {
local giturl=$(git config --get remote.origin.url | sed 's/git@/\/\//g' | sed 's/.git$//' | sed 's/https://g' | sed 's/:/\//g')
if [[ $giturl == "" ]]; then
echo "Not a git repository or no remote.origin.url is set."
else
local gitbranch=$(git rev-parse --abbrev-ref HEAD)
local giturl="http:${giturl}"
if [[ $gitbranch != "master" ]]; then
local giturl="${giturl}/tree/${gitbranch}"
fi
echo $giturl
open $giturl
fi
}
# Get colors in manual pages
function man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
# Runs a provided command for N repeats
function loop() {
number=$1
shift
for n in $(seq $number); do
$@
done
}
# Pipe my public key to my clipboard.
alias pubkey="more ~/.ssh/id_ed25519.pub | pbcopy | echo '=> Public key copied to pasteboard.'"
# Pipe my private key to my clipboard.
alias prikey="more ~/.ssh/id_ed25519 | pbcopy | echo '=> Private key copied to pasteboard.'"