Update fzf location
[dotfiles] / .bash_aliases
1 #!/bin/sh
2
3 alias m.gen.jwt="< /dev/urandom tr -dc A-Za-z0-9 | head -c32"
4
5 alias cat="ccat --bg='dark' "
6 alias empty_file=">| "
7 alias rmdirs="find . -type d -exec rm -rf '{}' \;"
8
9 alias please_update="sudo apt update && sudo apt upgrade -y"
10 alias trim_lws=" sed -e 's/^[[:space:]]*//'"
11 alias trim_tws=" sed -e 's/*[[:space:]]$//'"
12 alias trim=" sed -e 's/^[[:space:]]*//' | sed -e 's/*[[:space:]]$//'"
13
14
15 alias m.show_def="declare -f "
16 alias eox="ristretto "
17 alias m.containers.size="sudo du -sh /var/lib/lxd/storage-pools/default/containers/*"
18
19 alias m.sniff="wget -r -k -np --user-agent=Firefox "
20 alias m.tree="tree -I *.pyc"
21
22 alias m.path='echo "$PATH" | tr ":" "\n" | nl'
23 # alias m.path.2= echo "$PATH" | awk -v RS=':' '{print NR OFS $0}'
24
25 alias lsf='find . -maxdepth 1 -type f -print0 | xargs -0r ls'
26 alias m.lsh='ls -a | grep "^\."'
27 alias m.list_openfiles="sudo sysctl kern.openfiles"
28 alias m.list_opensockets="sudo sysctl kern.numopensockets"
29
30 alias m.ls_large_files="find / -size +10M -ls"
31 alias m.ls_large_folders=" du -a /var | sort -n -r | head -n 10"
32
33 alias m.pstree="ps axjf "
34 alias m.top="top -c -p $(pgrep -d',' -f string_to_match_in_cmd_line)"
35
36 alias m.rm_emacs_server="rm /tmp/emacs1000/server"
37
38 alias m.reload_conky="killall -SIGUSR1 conky"
39 #alias python="python3.8"
40
41 alias m.biggest_subdirs="du -sk * | sort -nr | head -10"
42 alias m.last_log="ls -ltr /var/log | tail"
43
44 alias mkcd=mkdircd
45
46 #alias xterm='xterm -font -*-truetype-*-*-18-*-*-*-*-*-iso8859-* -geometry 70x24'
47
48 #alias xterm="xterm -fn 9x18"
49
50 alias m.truetype_fonts="fc-list :fontformat=TrueType -f "%{family}" | sort -u | grep -i --color mona"
51 alias m.list_available_fonts="fc-list | awk -F':' '{print $2}' | sort"
52
53 alias duc="du -csh "
54 alias m.list_lxc_containers="netstat -ax | egrep '@.*/lxc/.*/command$'"
55
56 alias rustc='rustc --color auto '
57 alias ruste='rustc --explain'
58 alias rusto='rustc --out-dir bin/'
59
60 #alias fuck="sudo $(history -p \!\!)"
61
62 alias unmount="sudo umount"
63
64 alias m.pg_st="sudo systemctl status postgresql"
65 alias m.pg_rst="sudo systemctl restart postgresql"
66 alias m.ng_st="sudo systemctl status nginx"
67 alias m.ng_rst="sudo systemctl restart nginx"
68
69 alias ifdown="sudo ifdown "
70 alias ifup="sudo ifup "
71 alias ifconfig="sudo ifconfig "
72 alias m.ip2="ip a show br0|sed -n '3p'|awk '{print \$2}'"
73 alias nc="nc.traditional"
74
75 alias m.list_files_installed_by="dpkg -L "
76
77 alias beroot="sudo -i"
78 alias m.init_system="ps -p 1 -o command"
79 alias m.share_tty='gotty tmux new -A -s go_tty bash'
80 alias m.fqdn='hostname --fqdn'
81
82 alias E='SUDO_EDITOR="emacsclient" sudo -e'
83 alias m.lngst_line_in_file="wc -L"
84
85
86
87 # manually installed packages
88 alias m.installed_packages="apt search -F %p '~i!~M'"
89
90 # apt search ~i lists the installed packages
91 # grep -v "^i A" removes the lines starting with "i A" (automatically pulled in dependencies)
92 # cut -d " " -f 4 > clean.txt filters out the package names
93 alias m.installed_packages2="apt search ~i | grep -v '^i A' | cut -d ' ' -f 4"
94
95 # only to be done by root
96 # alias m.installed_pkg="zgrep -hE '^(Start-Date:|Commandline:)' $(ls -tr /var/log/apt/history.log*.gz ) | egrep -v 'aptdaemon|upgrade' | egrep -B1 '^Commandline: apt-get install'"
97
98 # alias m.installed_pkg2="( zcat $( ls -tr /var/log/apt/history.log*.gz ) ; cat /var/log/apt/history.log ) | egrep '^(Start-Date:|Commandline:)' | grep -v aptdaemon | egrep '^Commandline: apt-get install'"
99
100 # the grep I use the most
101 alias m.grp='mgrp() { grep --exclude-dir={.hg,.git,migrations,scss} --exclude=*.pyc -Hrnisl "$1" . ; } && mgrp'
102 alias nimcr="nim c -r"
103
104 alias m.current_shell="echo $0"
105 alias m.shells="cat /etc/shells"
106
107 alias mount="sudo mount"
108 alias umount="sudo umount"
109
110 alias m.public_ip="curl ifconfig.me"
111 alias m.dl_website="wget --random-wait -r -p -e robots=off -U mozilla "
112 alias m.dl_website2="wget robots=off -U mozilla \
113 --recursive \
114 --no-clobber \
115 --page-requisites \
116 --html-extension \
117 --convert-links \
118 --restrict-file-names=windows \
119 --domains website.org \
120 --no-parent "
121 alias m.poor_man_bandwith_monitor="watch -n1 'sudo ifconfig eth0 | grep RX' "
122
123 # curl retrieve header only when doing a post
124 # -D- dump header to stdout
125 # -s no progress bar
126 # -o/dev/null output body to /dev/null
127 alias curlh="curl -s -D- -o/dev/null "
128
129 # test disk read/write speed
130 alias m.disk_write_speed="dd if=/dev/zero of=/tmp/output.img bs=8k count=256k conv=fdatasync; rm -rf /tmp/output.img"
131 alias m.disk_read_speed="hdparm -Tt /dev/sda"
132
133 # generate random password, 16 char long
134 alias m.gen_pwd="LANG=c < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;"
135 alias m.gen_pwd2="openssl rand -base64 16"
136
137 # go to root dir
138 alias git-root='cd $(git rev-parse --show-cdup)'
139
140 alias m.installed_packages="dpkg --get-selections"
141 alias m.manually_installed_packages="apt search '~i !~M'"
142
143 alias m.tcp_sockets='ss -s'
144 alias m.tcp_sockets2='netstat -s'
145 alias m.open_ports2='ss -l'
146 alias m.open_ports='netstat -tupln'
147 alias m.open_tcp_port='netstat -plnt'
148
149 alias del="rm -rf"
150 alias rm="trash"
151
152 alias dj_secret_key="tr -dc 'a-z0-9!@#$%^&*(-_=+)' < /dev/urandom | head -c50"
153
154 # emacsclient is too long to write
155 alias mx="emacsclient -c -nw"
156
157 alias m.laptop_serial_number='sudo dmidecode -t 1 | grep -i serial'
158
159 alias m.show_user_process='ps wu -U'
160
161 alias fuck="sudo !!"
162 alias w-cl="find . -type f -name '* *.*' -exec bash -c 'mv "$0" "${0// /_}"' {} \;"
163
164 alias m.mu.terminate="pkill -2 -u $UID mu"
165 alias m.emacs.reboot="rmf /tmp/emacs1000/server && rmf .offlineimap/Gandi.lock && pkill -2 -u nsukami mu"
166 alias m.architecture='dpkg --print-architecture'
167 alias m.number_of_cores='cat /proc/cpuinfo |grep processor'
168 alias m.processor_info='cat /proc/cpuinfo'
169
170 alias ip='sudo ip'
171 alias dhclient='sudo dhclient'
172
173 alias m.debian_version='sudo cat /etc/debian_version'
174 alias m.ubuntu_version='sudo cat /etc/issue'
175 alias m.kernel_info='uname -a'
176 alias m.kernel_release='uname -r'
177
178
179 alias grep="grep --color=auto "
180 alias fgrep="fgrep --color=auto "
181 alias egrep="egrep --color=auto "
182
183 alias mkdir='mkdir -p'
184
185 alias m.processes='ps aux | grep '
186
187 # some more ls aliases
188 alias ls='ls --hide="*~" --color --group-directories-first'
189 alias dir='dir --color=auto'
190 alias vdir='vdir --color=auto'
191 alias ll='ls -lh'
192 alias la='ls -lah '
193 alias lt='ls -t '
194 alias lts='lt | head -n 6 '
195 alias lo="ls -l | awk '{print $9}'"
196
197 # some more mor aliases
198 alias apt="sudo apt"
199 alias aptitude="sudo aptitude"
200 alias service="sudo service"
201 alias halt='sudo halt'
202 alias reboot='sudo reboot'
203 alias wvdial='sudo wvdial'
204 alias apt-get='sudo apt-get'
205 alias dpkg='sudo dpkg'
206
207 alias h="history"
208 alias j="jobs -l"
209
210 alias ..="cd .."
211 alias ....="cd ../.."
212 alias ......="cd ../../.."
213
214 #git
215 alias gstatus='git status'
216 alias gcheckout='git checkout'
217 alias gcommit='git commit'
218 alias grebase='git rebase'
219 alias gbranch='git branch'
220 alias gpull='git pull'
221 alias gpush='git push'
222 alias gadd='git add'
223 alias gmergetool='git mergetool'
224 alias gdiff='git diff --color'
225 alias glog='git log --date-order --all --graph --format="%C(green)%h%Creset %C(yellow)%an%Creset %C(blue bold)%ar%Creset %C(red bold)%d%Creset%s"'
226 alias glog2='git log --date-order --all --graph --name-status --format="%C(green)%h%Creset %C(yellow)%an%Creset %C(blue bold)%ar%Creset %C(red bold)%d%Creset%s"'
227
228 alias du="du -kh" # Makes a more readable output.
229 alias df="df -kTh"
230
231 alias ifconfig='/sbin/ifconfig'
232 alias m.gatewayaddress="netstat -nr"
233
234 alias reload_tmuxconf="tmux source-file ~/.tmux.conf"
235 alias reload_bash="source ~/.bashrc"
236 alias reload_alsa="service alsa-utils restart"
237 alias reload_bluetooth='service bluetooth restart'
238
239 # virtualenv
240 alias m.wifi_list="sudo iw wlan0 scan | less"
241
242 alias m.top10_running_proc="ps aux | sort -nk +4 | tail"
243
244 # gpg
245 alias gpg_gen="gpg --gen-key "
246 alias gpg_ls="gpg --list-keys "
247 alias gpg_bckp_pubk="gpg -ao mypub.key --export "
248 alias gpg_bckp_privk="gpg -ao mypriv.key --export-secret-keys "
249 alias gpg_share_pubk="gpg --send-keys --keyserver "
250 alias gpg_search="gpg --search-keys --keyserver "
251 alias gpg_enc="gpg --encrypt --recipient "
252 alias gpg_dec="gpg --decrypt "
253
254 alias m.bios='sudo dmidecode -t 1 | grep "Manufacturer\|Product Name\|Serial Number" | tr -d "\t" | sed "s/Manufacturer//" && echo -ne "\nBIOS" && sudo dmidecode -t 0 | grep "Vendor\|Version\|Release" | tr -d "\t" | sed "s/Vendor//"'
255
256 alias ll5='ll -tl | head -4'
257
258
259 # m.add_system_user="sudo adduser --system --no-create-home"
260
261 alias ipython='ipython3 --profile=nsukami'
262
263
264 # keyboard
265 alias m.key.list_ids="xmodmap -pke"
266 alias m.key.find_ids="xev"
267 alias m.key.reset_keymap="setxkbmap" # or setxkbmap -option
268
269 # https://wiki.archlinux.org/index.php/Xmodmap
270
271 # note the info:
272 # >> xmodmap -pm
273 # xmodmap: up to 4 keys per modifier, (keycodes in parentheses):
274 #
275 # shift Shift_L (0x32), Shift_R (0x3e)
276 # lock Caps_Lock (0x42)
277 # control Control_L (0x25), Control_R (0x69)
278 # mod1 Alt_L (0x40), Meta_L (0xcd)
279 # mod2 Num_Lock (0x4d)
280 # mod3
281 # mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
282 # mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
283
284 #
285 # if you intend to assign Caps_Lock to your A key and B to your NumLock key,
286 # you need to first clear the modifiers for both Caps_Lock and Num_Lock,
287 # then assign the keysyms, and finally add back the modifiers
288
289 # ctrl l keycode 37 (keysym 0xffe3, Control_L),
290 # esc keycode 9 (keysym 0xff1b, Escape)
291 # ctr r keycode 105 (keysym 0xffe4, Control_R)
292
293 # remap: xmodmap -e "keycode 9 = Control_L"
294 # clear: xmodmap -e "clear Shift" # valid names are Shift, Lock, Control, Mod1, Mod2, Mod3, Mod4, and Mod5
295 #