[zsh/vim/irssi/...] My home files
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

.aliases 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. # Aliases
  2. alias l="ls --color=auto -lh"
  3. alias ll="ls --color=auto -alh"
  4. alias ls="ls --color=auto -h"
  5. alias grep="grep --color=auto"
  6. alias less="less -r"
  7. alias update="sudo apt update"
  8. alias upgrade="sudo apt upgrade"
  9. alias full-update="update && upgrade"
  10. alias i="sudo apt install"
  11. alias purge="sudo apt purge"
  12. alias s="apt search"
  13. alias vim="vim -p"
  14. alias zshrc="vim ~/.zshrc && source ~/.zshrc"
  15. alias aliases="vim ~/.aliases && source ~/.aliases"
  16. alias vimrc="vim ~/.vimrc"
  17. alias calc.exe="python3"
  18. # System aliases
  19. alias dodo="sudo shutdown now -h"
  20. alias goodnight="sudo shutdown -h +90"
  21. alias SX="startx &; disown startx; exit"
  22. # Misc
  23. alias commit="curl -s http://whatthecommit.com/index.txt"
  24. alias report="pandoc -V geometry:margin=1in -V fontsize:11pt"
  25. alias latexclean="rm *.aux; rm *.log; rm *.out; rm *.toc; rm *.snm; rm *.nav"
  26. alias CleanKernel="dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p' | xargs sudo apt-get -y purge"
  27. alias poogle="ping google.com"
  28. alias moc="mocp -T transparent-background"
  29. alias starwars="telnet towel.blinkenlights.nl"
  30. alias PrimeNumbers="bash -c 'for i in {2..100};{ for((z=k=i;k-->2;)){((z=z&&i%k));}&&echo $i;}'"
  31. alias eyesaver="notify-send -t 10000 -u critical \"EYE SAVER\" \"Launching eye saver\"; while true; do sleep $[15*60]; notify-send -t 10000 -u critical \"EYE SAVER \" \"Just look outside your screen for a few seconds\!\"; done"
  32. alias diapo="feh -D 4 -FrZ"
  33. alias StartGPGAgent="gpg-agent --enable-ssh-support --daemon"
  34. # SSH aliases
  35. alias DagobahWAN="ssh skia@dagobah.libskia.so"
  36. alias AlderaanWAN="ssh skia@alderaan.libskia.so"
  37. alias Libskia.so="ssh skia@libskia.so -A"
  38. #########################
  39. # Kernel work functions #
  40. #########################
  41. Rootfs_cpio_gz () {
  42. find "$1" | cpio -o -H newc | gzip > "$1/../rootfs.cpio.gz"
  43. }
  44. Rootfs_cpio_gz_to_uboot_img () {
  45. mkimage -A arm -O linux -T ramdisk -C gzip -d "$1" "$1.uboot"
  46. }
  47. Modules_to_cpiogz_rootfs () {
  48. rootfs=$(basename $1 .cpio.gz)
  49. modules=$2
  50. tmpdir=./tmp
  51. gzip -d -f ${rootfs}.cpio.gz
  52. mkdir $tmpdir
  53. cd $tmpdir
  54. cpio -i -F ../${rootfs}.cpio
  55. tar --selinux -xaf ../$modules
  56. find . | cpio -o -H newc | gzip > ../rootfs_with_modules.cpio.gz
  57. cd ..
  58. rm -rf $tmpdir
  59. }
  60. ##############################
  61. # Misc functions and helpers #
  62. ##############################
  63. # Pause music and go to suspend
  64. DifferedSleep () {
  65. if [ $# -ne 1 ]; then
  66. echo "Usage: $0 TIME";
  67. else
  68. minutes=$[60*$1]
  69. echo "Going to sleep in $minutes seconds ($1 minutes)"
  70. sleep $minutes;
  71. echo "Pausing mocp"
  72. mocp -G
  73. echo "Going to sleep"
  74. systemctl suspend
  75. fi
  76. }
  77. # Prepend the year to music albums
  78. AddYear() {
  79. mv $1 "$2 - $1"
  80. }
  81. # Move $1 to $2 and replace $1 by a relative symlink to $2
  82. mvln () {
  83. if [ "$1" = "" ] || [ "$2" = "" ]; then
  84. cat - <<EOF
  85. Usage: $0 SRC DST
  86. Move SRC to DST and replace SRC by a relative symlink to DST
  87. EOF
  88. return 1
  89. fi
  90. SRC=$1
  91. DST=$2
  92. SRC_NAME=$(basename "$SRC")
  93. SRC_DIR=$(dirname "$SRC")
  94. if [ -d "$DST" ]; then
  95. DST_NAME=$(basename "$SRC")
  96. DST_DIR="$DST"
  97. else
  98. DST_NAME=$(basename "$DST")
  99. DST_DIR=$(dirname "$DST")
  100. fi
  101. mv "$SRC" "$DST"
  102. ln -s "$DST_DIR/$DST_NAME" "$SRC_DIR/$SRC_NAME"
  103. }
  104. # Lock the session
  105. lock () {
  106. scrot /tmp/screenshot.png
  107. convert /tmp/screenshot.png -blur 5x5 /tmp/lock.png
  108. i3lock -i /tmp/lock.png
  109. }
  110. # Useful for tea time
  111. timer () {
  112. sleep $[$1*60]
  113. beep
  114. echo -e "\a"
  115. }
  116. # Just try it :)
  117. darkvador() {
  118. A="440"
  119. Ab="415.3"
  120. F="349.2"
  121. C="523.2"
  122. E="659.3"
  123. HF="698.5"
  124. beep -f $A -l 600; sleep 0.1
  125. beep -f $A -l 600; sleep 0.1
  126. beep -f $A -l 600; sleep 0.1
  127. beep -f $F -l 450; sleep 0.1
  128. beep -f $C -l 150; sleep 0.1
  129. beep -f $A -l 600; sleep 0.1
  130. beep -f $F -l 450; sleep 0.1
  131. beep -f $C -l 150; sleep 0.1
  132. beep -f $A -l 1200; sleep 0.1
  133. beep -f $E -l 600; sleep 0.1
  134. beep -f $E -l 600; sleep 0.1
  135. beep -f $E -l 600; sleep 0.1
  136. beep -f $HF -l 450; sleep 0.1
  137. beep -f $C -l 150; sleep 0.1
  138. beep -f $Ab -l 600; sleep 0.1
  139. beep -f $F -l 450; sleep 0.1
  140. beep -f $C -l 150; sleep 0.1
  141. beep -f $A -l 1200; sleep 0.1
  142. }
  143. ######################
  144. # Multimedia helpers #
  145. ######################
  146. # Music conversion
  147. Mp3ToOgg() {
  148. find -type f -name "*.mp3" -print0 | while read -d $'\0' a; do
  149. ffmpeg -i "$a" -vsync 2 "${a[@]/%mp3/ogg}"
  150. done
  151. }
  152. FlacToOpus() {
  153. find -type f -name "*.flac" -print0 | while read -d $'\0' a; do
  154. opusenc --bitrate 192 "$a" "${a[@]/%flac/opus}"
  155. done
  156. }
  157. FlacToMp3() {
  158. find -type f -name "*.flac" -print0 | while read -d $'\0' a; do
  159. # give output correct extension
  160. OUTF="${a[@]/%flac/mp3}"
  161. # get the tags
  162. ARTIST=$(metaflac "$a" --show-tag=ARTIST |sed s/.*=//g)
  163. TITLE=$(metaflac "$a" --show-tag=TITLE |sed s/.*=//g)
  164. ALBUM=$(metaflac "$a" --show-tag=ALBUM |sed s/.*=//g)
  165. GENRE=$(metaflac "$a" --show-tag=GENRE |sed s/.*=//g)
  166. TRACKNUMBER=$(metaflac "$a" --show-tag=TRACKNUMBER |sed s/.*=//g)
  167. DATE=$(metaflac "$a" --show-tag=DATE |sed s/.*=//g)
  168. # stream flac into the lame encoder
  169. flac -c -d "$a" | lame -V0 --add-id3v2 --pad-id3v2 --ignore-tag-errors \
  170. --ta "$ARTIST" --tt "$TITLE" --tl "$ALBUM" --tg "${GENRE:-12}" \
  171. --tn "${TRACKNUMBER:-0}" --ty "$DATE" - "$OUTF"
  172. done
  173. }
  174. # Videos handling
  175. # This merges all the files beginning with $1 into a single mkv file
  176. MergetoMKV() {
  177. mkvmerge -o "tmp_$1" $1.*
  178. rm $1.*
  179. mv "tmp_$1" "$1.mkv"
  180. }
  181. # End of general aliases, time to load local ones
  182. if [ -f ~/.aliases.local ]; then
  183. source ~/.aliases.local
  184. fi