blob: ebe3481f10cbe0a08b48db9adc6498d964c89446 (
plain)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
##
# Aliases and functions
#
alias '...'='../..'
ls_options=('--almost-all' '--classify' '--color=auto'
'--human-readable' '--group-directories-first')
alias ls='\ls "${ls_options[@]}"'
alias ll='\ls "${ls_options[@]}" -l'
alias grep='\grep --color'
alias mkdir='mkdir -vp'
alias df='df -h'
alias acp='acp -g'
alias amv='amv -g'
alias ncmpcpp='ncmpcpp -c ~/.config/ncmpcpp/config'
alias wefree='weechat -a -r "/connect Freenode"'
alias ms='mbsync --config "$XDG_CONFIG_HOME/mbsyncrc" theos'
alias ms5='mbsync --config "$XDG_CONFIG_HOME/mbsyncrc" 5monkeys'
alias msa='mbsync --config "$XDG_CONFIG_HOME/mbsyncrc" -a'
alias ty='ttytter -rc="$XDG_CONFIG_HOME"/ttytter/ttytterrc'
alias pt='pstree --highlight-all --long --uid-changes'
alias sprin='curl -F "sprunge=<-" http://sprunge.us'
sprfile() {
curl -F "sprunge=<$1" http://sprunge.us
}
# Colored man
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 "$@"
}
sp() { printf '%s' "$@"; printf '\n'; }
have() { command -v "$1" >&/dev/null; }
# Print basic prompt to the window title
function precmd {
print -Pn "\e];%n %~\a"
}
# Print the current running command's name to the window title
function preexec {
local cmd=${1[(wr)^(*=*|sudo|exec|ssh|-*)]}
print -Pn "\e];$cmd:q\a"
}
# service management
if have systemctl && [[ -d /run/systemd/system ]]; then
alias ssctl='sudo systemctl'
alias userctl='systemctl --user'
alias list='systemctl list-units -t path,service,socket --no-legend'
alias ulist='userctl list-units -t path,service,socket --no-legend'
alias lcstatus='loginctl session-status $XDG_SESSION_ID'
alias tsd='tree /etc/systemd/system'
cgls() { SYSTEMD_PAGER='cat' systemd-cgls "$@"; }
usls() { cgls "/user.slice/user-$UID.slice/$*"; }
psls() { cgls "/user.slice/user-$UID.slice/session-$XDG_SESSION_ID.scope"; }
fi
function 5v {
if [[ -d "$HOME"/venvs/"$1" ]]; then
source "$HOME"/venvs/"$1"/bin/activate
printf "\x1b[38;5;2m==> 5venv ‘%s’ activated successfully.\x1b[0m\n" "$1"
else
printf "==> 5venv ‘%s’ not found\n" "$1"
printf "==> Create? [yN]: "
read yn
if [[ "$yn" == 'y' || "$yn" == 'yes' ]]; then
printf "==> Python version? [23]: "
read venvver
if [[ "$venvver" == '2' ]]; then
virtualenv2 "$HOME"/venvs/"$1"
if (( $? == 0 )); then
print "\x1b[38;5;2m==> 5venv created successfully, installing basic requirements.\x1b[0m"
else
print "\x1b[38;5;1m==> Error: 5env creation failed. Exiting.\x1b[0m"
return 1
fi
source "$HOME"/venvs/"$1"/bin/activate
pip install -r "$HOME"/venvs/5_requirements.txt
elif [[ "$venvver" == '3' ]]; then
virtualenv3 "$HOME"/venvs/"$1"
if (( $? == 0 )); then
print "\x1b[38;5;2m==> 5venv created successfully, activating environment.\x1b[0m"
print "==> Note that no requirements were installed due to version 3 was selected."
else
print "\x1b[38;5;1m==> Error: 5env creation failed. Exiting.\x1b[0m"
return 1
fi
source "$HOME"/venvs/"$1"/bin/activate
else
printf "==> virtualenv for version ‘%s’ not found.\n" "$venvver"
exit 1
fi
fi
fi
}
function 5c {
cd "$HOME"/projects/"$1"
}
function 5clone {
if [[ -z "$1" ]]; then
print "No repo name"
fi
(cd "$HOME"/projects
git clone git@github.com:5m/"$1"
shift
cd -)
pushd "$HOME"/projects/"$1"
git config --local user.email johannes@5monkeys.se
}
alias 5ssh='TERM=xterm ssh'
aur-push() {
git push aur@aur.archlinux.org:/"$1".git "$1":master
}
aur-pull() {
local old_branch=$(git symbolic-ref --short HEAD)
git checkout "$1"
git pull aur@aur.archlinux.org:/"$1".git master:"$1"
git checkout "$old_branch"
}
tt() {
if [[ -n "$@" ]]; then
print "$@" | ts '[%Y-%m-%d %H:%M:%S]' >> "$HOME"/documents/timetracking
fi
}
|