Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

207 linhas
5.0KB

  1. #
  2. # ~/.bashrc
  3. #
  4. export PREFIX=$HOME/.$(whoami)/
  5. ## git
  6. ######
  7. #source ~/.bash-git-prompt/gitprompt.sh
  8. alias gs="git status"
  9. alias gl="git log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
  10. alias gp="git pull"
  11. function lastweek() {
  12. git shortlog -sne --since="$(date --date='7 days ago')" --before="$(date)"
  13. }
  14. function gc() {
  15. if (npm run lint); then
  16. git commit -m "$1"
  17. fi
  18. }
  19. ## ssh keygen
  20. #############
  21. alias newpubkey='ssh-keygen -f ~/.ssh/id_rsa -y'
  22. alias fingerprint='ssh-keygen -lf ~/.ssh/id_rsa.pub'
  23. ## lazy
  24. #######
  25. alias mp3="mplayer *.mp3"
  26. alias n="nano"
  27. alias nani="nano"
  28. alias zram="modprobe zram && echo $((3072*1024*1024)) > /sys/block/zram0/disksize && mkswap /dev/zram0 && swapon -p 60 /dev/zram0"
  29. # mplayer vaapi
  30. alias m="mplayer -vo vaapi -va vaapi"
  31. function h () {
  32. grep "$1" ~/.bash_history
  33. }
  34. ## lua
  35. ######
  36. function lua_environment () {
  37. if (("$#" == 1)); then
  38. if [ $1 == "51" ]; then
  39. eval $(luarocks-5.1 path)
  40. elif [ $1 == "52" ]; then
  41. eval $(luarocks-5.2 path)
  42. elif [ $1 == "53" ]; then
  43. eval $(luarocks-5.3 path)
  44. fi
  45. fi
  46. }
  47. alias uselua="lua_environment"
  48. export LUA_CPATH=$HOME/.$(whoami)/lib/lua/5.3/?.so
  49. ## matlab/octave
  50. ################
  51. # alias matlab="/home/markus/MATLAB/bin/matlab"
  52. # alias m="/home/markus/MATLAB/bin/matlab -nodesktop -nosplash"
  53. alias o="octave-cli"
  54. ## local compiles
  55. #################
  56. export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/.$(whoami)/lib"
  57. # set PATH so it includes user's private bin if it exists
  58. if [ -d "$HOME/.$(whoami)/bin" ] ; then
  59. export PATH="$HOME/.$(whoami)/bin:$HOME/.$(whoami)/usr/bin:$HOME/.$(whoami)/usr/local/bin:$PATH"
  60. fi
  61. if [ -d "$HOME/.$(whoami)/lib/pkgconfig" ]; then
  62. export PKG_CONFIG_PATH="$HOME/.$(whoami)/lib/pkgconfig"
  63. fi
  64. if [ $(uname) = "NetBSD" ]; then
  65. PKG_PATH="http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/7.0/All/"
  66. export PKG_PATH
  67. fi
  68. ### autojump
  69. # https://github.com/wting/autojump
  70. if [ -f "/usr/share/autojump/autojump.bash" ]; then
  71. source /usr/share/autojump/autojump.bash
  72. fi
  73. ## wttr.in
  74. function wttr () {
  75. curl wttr.in/"$1"
  76. }
  77. alias wetter="wttr"
  78. # gnumeric with english numeric notation
  79. alias gnumeric='LC_NUMERIC="en" gnumeric'
  80. # local webserver
  81. alias ws="python -m http.server 8000"
  82. export EDITOR=nano
  83. ## netstat without netstat
  84. # https://staaldraad.github.io/2017/12/20/netstat-without-netstat/
  85. function _netstat() {
  86. awk 'function hextodec(str,ret,n,i,k,c){
  87. ret = 0
  88. n = length(str)
  89. for (i = 1; i <= n; i++) {
  90. c = tolower(substr(str, i, 1))
  91. k = index("123456789abcdef", c)
  92. ret = ret * 16 + k
  93. }
  94. return ret
  95. }
  96. function getIP(str,ret){
  97. ret=hextodec(substr(str,index(str,":")-2,2));
  98. for (i=5; i>0; i-=2) {
  99. ret = ret"."hextodec(substr(str,i,2))
  100. }
  101. ret = ret":"hextodec(substr(str,index(str,":")+1,4))
  102. return ret
  103. }
  104. NR > 1 {{if(NR==2)print "Local - Remote";local=getIP($2);remote=getIP($3)}{print local" - "remote}}' /proc/net/tcp
  105. }
  106. alias ns=_netstat
  107. function _docker_tabula_rasa(){
  108. docker rm $(docker ps -a -q) --force
  109. docker rmi $(docker images -q) --force
  110. yes|docker system prune
  111. docker volume rm $(docker volume ls -q --filter dangling=true) --force
  112. }
  113. alias updatebash="source ~/.bashrc"
  114. function _rip_audio() {
  115. if (("$#" != 1)); then
  116. echo "source is missing..."
  117. else
  118. youtube-dl --prefer-ffmpeg --embed-thumbnail --add-metadata --metadata-from-title "%(artist)s - %(title)s" --audio-quality 0 --audio-format mp3 --extract-audio "$1"
  119. fi
  120. }
  121. function set_enc_clipboard() {
  122. xclip -out -selection clipboard | redis-cli -h 10.0.0.59 -x SET A
  123. }
  124. function get_enc_clipboard() {
  125. redis-cli -h 10.0.0.59 GET A | xclip -selection c
  126. }
  127. function o() {
  128. docker run --rm -ti --network dev --name octave -v $(pwd):~/ registry.gitlab.com/markuman/dev/octave:4.2.0 bash
  129. }
  130. function aur() {
  131. if (("$#" != 1)); then
  132. echo "source is missing..."
  133. else
  134. cd ~/aur
  135. git clone https://aur.archlinux.org/"$1".git
  136. cd $1
  137. makepkg
  138. fi
  139. }
  140. function awsenv() {
  141. if (("$#" != 1)); then
  142. cmp --silent ~/.aws/credentials ~/.aws/credentials.prod && echo "your're using PROD" || echo "you're using TEST"
  143. elif [ "$1" = "prod" ]; then
  144. cp ~/.aws/credentials.prod ~/.aws/credentials
  145. elif [ "$1" = "test" ]; then
  146. cp ~/.aws/credentials.test ~/.aws/credentials
  147. fi
  148. }
  149. alias x11orwayland="loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type"
  150. alias hosts="grep 'Host ' ~/.ssh/config"
  151. alias fail="tail -f"
  152. function _export(){
  153. if [ -z "$XONSH_ENCODING" ]
  154. then
  155. # this is not xonsh
  156. command export $@
  157. else
  158. # this is xonsh
  159. bash -c ! export $@
  160. fi
  161. }
  162. alias export=_export
  163. alias ap=ansible-playbook
  164. alias passgen='od -N 4 -t uL -An /dev/urandom | tr -d " "+%s | sha256sum | base64 | head -c 32 ; echo'
  165. function redis-ping() {
  166. # ping a redis server at any cost
  167. redis-cli -h $1 ping 2>/dev/null || \
  168. echo $((printf "PING\r\n";) | nc $1 6379 2>/dev/null || \
  169. exec 3<>/dev/tcp/$1/6379 && echo -e "PING\r\n" >&3 && head -c 7 <&3)
  170. }