Assume sudo for ifdown, ifup, ifconfig commands.
[dotfiles] / .bash_aliases
1 #!/bin/sh
2
3 alias ifdown="sudo ifdown "
4 alias ifup="sudo ifup "
5 alias ifconfig="sudo ifconfig "
6
7 alias my_list_files_installed_by="dpkg -L "
8
9 alias beroot="sudo -i"
10 alias my_init_system="ps -p 1 -o command"
11 alias my_share_tty='gotty tmux new -A -s go_tty bash'
12 alias my_fqdn='hostname --fqdn'
13 alias rustc='rustc --color auto '
14 alias E='SUDO_EDITOR="emacsclient" sudo -e'
15 alias my_lngst_line_in_file="wc -L"
16
17 alias rmf="rm -rf"
18 alias vnv="pyvenv"
19 alias venv="pyvenv"
20
21 # manually installed packages
22 alias my_installed_packages="apt search -F %p '~i!~M'"
23
24 # apt search ~i lists the installed packages
25 # grep -v "^i A" removes the lines starting with "i A" (automatically pulled in dependencies)
26 # cut -d " " -f 4 > clean.txt filters out the package names
27 alias my_installed_packages2="apt search ~i | grep -v '^i A' | cut -d ' ' -f 4"
28
29 # only to be done by root
30 # alias my_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'"
31
32 # alias my_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'"
33
34 # the grep I use the most
35 alias my_grep="grep -Hrnisl"
36
37 # my weird aliases
38 alias djo_runserver="python manage.py runserver"
39 alias djo_shell="python manage.py shell"
40 alias djo_shellp="python manage.py shell_plus"
41 alias djo_make="python manage.py makemigrations"
42 alias djo_mig="python manage.py migrate"
43 alias djo_csu="python manage.py createsuperuser"
44 alias djo_smtpd="python -m smtpd -n -c DebuggingServer localhost:1025"
45
46 alias nimcr="nim c -r"
47
48 alias my_current_shell="echo $0"
49 alias my_shells="cat /etc/shells"
50
51 alias mount="sudo mount"
52 alias umount="sudo umount"
53
54 alias my_public_ip="curl ifconfig.me"
55 alias my_dl_website="wget --random-wait -r -p -e robots=off -U mozilla "
56 alias my_dl_website2="wget robots=off -U mozilla \
57 --recursive \
58 --no-clobber \
59 --page-requisites \
60 --html-extension \
61 --convert-links \
62 --restrict-file-names=windows \
63 --domains website.org \
64 --no-parent "
65 alias my_poor_man_bandwith_monitor="watch -n1 'sudo ifconfig eth0 | grep RX' "
66
67 # curl retrieve header only when doing a post
68 # -D- dump header to stdout
69 # -s no progress bar
70 # -o/dev/null output body to /dev/null
71 alias curlh="curl -s -D- -o/dev/null "
72
73 # test disk read/write speed
74 alias my_disk_write_speed="dd if=/dev/zero of=/tmp/output.img bs=8k count=256k conv=fdatasync; rm -rf /tmp/output.img"
75 alias my_disk_read_speed="hdparm -Tt /dev/sda"
76
77 # generate random password, 16 char long
78 alias my_gen_pwd="LANG=c < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;"
79 alias my_gen_pwd2="openssl rand -base64 16"
80
81 # go to root dir
82 alias git-root='cd $(git rev-parse --show-cdup)'
83
84 alias my_installed_packages="dpkg --get-selections"
85 alias my_manually_installed_packages="apt search '~i !~M'"
86
87 alias my_tcp_sockets='ss -s'
88 alias my_tcp_sockets2='netstat -s'
89 alias my_open_ports2='ss -l'
90 alias my_open_ports='netstat -tupln'
91 alias my_open_tcp_port='netstat -plnt'
92
93
94 # emacsclient is too long to write
95 alias emax="emacsclient -cnw"
96
97 alias my_laptop_serial_number='sudo dmidecode -t 1 | grep -i serial'
98
99 alias my_show_user_process='ps wu -U'
100
101 alias fuck="sudo !!"
102
103
104 alias my_send_email="emacsclient -cnw --eval '(mail)'"
105 alias my_emails="emacsclient -cnw --eval '(gnus)'"
106
107 alias my_architecture='dpkg --print-architecture'
108 alias my_number_of_cores='cat /proc/cpuinfo |grep processor'
109
110 alias ip='sudo ip'
111 alias dhclient='sudo dhclient'
112
113 alias my_debian_version='sudo cat /etc/debian_version'
114 alias my_ubuntu_version='sudo cat /etc/issue'
115 alias my_kernel_info='uname -a'
116 alias my_kernel_release='uname -r'
117
118 alias emacs="emacs -nw"
119 alias grep="grep --color=auto"
120 alias fgrep="fgrep --color=auto"
121 alias egrep="egrep --color=auto"
122
123 alias mkdir='mkdir -p'
124
125 alias my_processes='ps aux | grep'
126
127 # some more ls aliases
128 alias ls='ls --hide="*~" --color'
129 alias dir='dir --color=auto'
130 alias vdir='vdir --color=auto'
131 alias ll='ls -lh'
132 alias la='ls -lah'
133 alias lt='ls -t'
134
135 # some more mor aliases
136 alias apt="sudo apt"
137 alias aptitude="sudo aptitude"
138 alias service="sudo service"
139 alias halt='sudo halt'
140 alias wvdial='sudo wvdial'
141 alias apt-get='sudo apt-get'
142 alias dpkg='sudo dpkg'
143
144 alias h="history"
145 alias j="jobs -l"
146
147 alias ..="cd .."
148 alias ....="cd ../.."
149 alias ......="cd ../../.."
150
151 #git
152 alias gstatus='git status'
153 alias gcheckout='git checkout'
154 alias gcommit='git commit'
155 alias grebase='git rebase'
156 alias gbranch='git branch'
157 alias gpull='git pull'
158 alias gpush='git push'
159 alias gadd='git add'
160 alias gmergetool='git mergetool'
161 alias gdiff='git diff --color'
162 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"'
163 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"'
164
165 alias du="du -kh" # Makes a more readable output.
166 alias df="df -kTh"
167
168 alias ifconfig='/sbin/ifconfig'
169 alias sshx='ssh dev_server'
170 alias my_gatewayaddress="netstat -nr"
171
172 alias reload_tmuxconf="tmux source-file ~/.tmux.conf"
173 alias reload_bash="source ~/.bashrc"
174 alias reload_alsa="service alsa-utils restart"
175 alias reload_bluetooth='service bluetooth restart'
176
177 # virtualenv
178 alias my_wifi_list="sudo iw wlan0 scan | less"
179
180 alias my_top10_running_proc="ps aux | sort -nk +4 | tail"
181
182 # gpg
183 alias gpg_gen="gpg --gen-key "
184 alias gpg_ls="gpg --list-keys "
185 alias gpg_bckp_pubk="gpg -ao mypub.key --export "
186 alias gpg_bckp_privk="gpg -ao mypriv.key --export-secret-keys "
187 alias gpg_share_pubk="gpg --send-keys --keyserver "
188 alias gpg_search="gpg --search-keys --keyserver "
189 alias gpg_enc="gpg --encrypt --recipient "
190 alias gpg_dec="gpg --decrypt "
191
192 alias my_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//"'
193
194 alias ll5='ll -tl | head -4'