My configuration files for Debian/Ubuntu applications
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.
 
 
 
 
 
 

307 linhas
8.5 KiB

  1. # ~/.bashrc: executed by bash(1) for non-login shells.
  2. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
  3. # for examples
  4. # If not running interactively, don't do anything
  5. case $- in
  6. *i*) ;;
  7. *) return;;
  8. esac
  9. # don't put duplicate lines or lines starting with space in the history.
  10. # See bash(1) for more options
  11. HISTCONTROL=ignoreboth
  12. # append to the history file, don't overwrite it
  13. shopt -s histappend
  14. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  15. HISTSIZE=1000
  16. HISTFILESIZE=2000
  17. # check the window size after each command and, if necessary,
  18. # update the values of LINES and COLUMNS.
  19. shopt -s checkwinsize
  20. # If set, the pattern "**" used in a pathname expansion context will
  21. # match all files and zero or more directories and subdirectories.
  22. #shopt -s globstar
  23. # make less more friendly for non-text input files, see lesspipe(1)
  24. #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  25. # set variable identifying the chroot you work in (used in the prompt below)
  26. if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
  27. debian_chroot=$(cat /etc/debian_chroot)
  28. fi
  29. # set a fancy prompt (non-color, unless we know we "want" color)
  30. case "$TERM" in
  31. xterm-color|*-256color) color_prompt=yes;;
  32. esac
  33. # uncomment for a colored prompt, if the terminal has the capability; turned
  34. # off by default to not distract the user: the focus in a terminal window
  35. # should be on the output of commands, not on the prompt
  36. #force_color_prompt=yes
  37. if [ -n "$force_color_prompt" ]; then
  38. if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  39. # We have color support; assume it's compliant with Ecma-48
  40. # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  41. # a case would tend to support setf rather than setaf.)
  42. color_prompt=yes
  43. else
  44. color_prompt=
  45. fi
  46. fi
  47. if [ "$color_prompt" = yes ]; then
  48. PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  49. else
  50. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  51. fi
  52. unset color_prompt force_color_prompt
  53. # If this is an xterm set the title to user@host:dir
  54. case "$TERM" in
  55. xterm*|rxvt*)
  56. PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  57. ;;
  58. *)
  59. ;;
  60. esac
  61. # enable color support of ls and also add handy aliases
  62. if [ -x /usr/bin/dircolors ]; then
  63. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  64. alias ls='ls --color=auto'
  65. #alias dir='dir --color=auto'
  66. #alias vdir='vdir --color=auto'
  67. #alias grep='grep --color=auto'
  68. #alias fgrep='fgrep --color=auto'
  69. #alias egrep='egrep --color=auto'
  70. fi
  71. # colored GCC warnings and errors
  72. #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
  73. # some more ls aliases
  74. #alias ll='ls -l'
  75. #alias la='ls -A'
  76. #alias l='ls -CF'
  77. # Alias definitions.
  78. # You may want to put all your additions into a separate file like
  79. # ~/.bash_aliases, instead of adding them here directly.
  80. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  81. if [ -f ~/.bash_aliases ]; then
  82. . ~/.bash_aliases
  83. fi
  84. # enable programmable completion features (you don't need to enable
  85. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  86. # sources /etc/bash.bashrc).
  87. if ! shopt -oq posix; then
  88. if [ -f /usr/share/bash-completion/bash_completion ]; then
  89. . /usr/share/bash-completion/bash_completion
  90. elif [ -f /etc/bash_completion ]; then
  91. . /etc/bash_completion
  92. fi
  93. fi
  94. # Directory changes
  95. alias cdn='vim ~/Notes "+cd ~/Notes" "+enew" "+CtrlP"'
  96. alias cdd='cd $HOME/Downloads/'
  97. alias cdo='cd $HOME/Source/'
  98. alias cdc='cd $HOME/.config/'
  99. alias cd-projects='cd $HOME/Projects/'
  100. alias cd-x='cd $HOME/Encrypted/x/'
  101. alias cd-vim='cd /usr/share/vim/vim82/pack/my-plugins/start'
  102. alias cdz='cd $((mru listdirs | fzf --height=50%) || printf ".")'
  103. # General
  104. alias v='vim'
  105. alias yt='youtube-dl'
  106. alias ytb='youtube-dl --no-progress'
  107. alias depth='echo $SHLVL'
  108. alias lsg='ls -la | grep' #Determines if a file or folder with a name containing a sequence of characters is in the current directory
  109. alias show='apt show'
  110. alias lynx='lynx -vikeys'
  111. alias lsa='ls -laF'
  112. alias doihave='apt list --installed'
  113. alias email='neomutt'
  114. # Utilities
  115. alias ins='sudo apt-get install'
  116. alias uns='sudo apt-get purge'
  117. alias update='sudo apt-get update; sudo apt-get upgrade;'
  118. alias nnn='nnn -xE'
  119. alias do-xbind='xbindkeys -f $HOME/Source/configs/xbindkeysrc'
  120. alias get-rndnum='head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8'
  121. alias music="ncmpcpp"
  122. alias chat="irssi"
  123. alias t="task"
  124. alias record-window='recordmydesktop --full-shots --windowid $(xwininfo | grep "id: 0x" |
  125. grep -Eo "0x[a-z0-9]+")'
  126. # Programming
  127. alias py='ipython3 --TerminalInteractiveShell.editing_mode=vi'
  128. alias g='git'
  129. alias gc='git clone'
  130. alias gs='git status'
  131. alias ga='git add'
  132. alias gb='git branch'
  133. alias gl='git log'
  134. alias gd='git diff'
  135. # Edit config and system files
  136. alias edit-bashrc='vim $HOME/.bashrc'
  137. alias edit-profile='vim $HOME/.profile'
  138. alias edit-vimrc='sudo vim /etc/vim/vimrc.local'
  139. alias edit-xkb='vim $HOME/.config/xkb/custom.xkb'
  140. alias edit-xr='vim ~/.config/xfiles/Xresources'
  141. alias edit-sources='sudo vim /etc/apt/sources.list'
  142. alias edit-tmux='vim $HOME/.config/tmux/tmux.conf'
  143. alias edit-git='vim $HOME/.config/git/config'
  144. alias load-xr='xrdb ~/.config/xfiles/Xresources'
  145. alias load-xkb='xkbcomp $HOME/.config/xkb/custom.xkb $DISPLAY'
  146. alias load-xt='xrdb $HOME/.config/Xresources'
  147. alias load-profile='source $HOME/.profile'
  148. alias lo='load-profile'
  149. alias betterXev="xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf \"%-3s %s\\n\", $5, $8 }'"
  150. # Encryption
  151. alias mntx='encfs $HOME/Encrypted/.x/ $HOME/Encrypted/x/'
  152. alias umntx='encfs -u $HOME/Encrypted/x/'
  153. # Applications
  154. alias scan='sudo arp-scan 192.168.0.1/24'
  155. alias weechat='weechat -d "$XDG_CONFIG_HOME"/weechat'
  156. #Special functions! :D
  157. search() {
  158. apt search $@ | less
  159. }
  160. clean() {
  161. #Check if there is too many arguments
  162. if [ "$#" -gt "1" ]
  163. then
  164. echo "Too many arguments. There are $#."
  165. return
  166. fi
  167. case "$1" in
  168. '')
  169. ;;
  170. soft)
  171. history -c ;;
  172. hard)
  173. history -c
  174. rm -r $HOME/tmp/; mkdir $HOME/tmp/ ;;
  175. *)
  176. echo "Invalid arguments"; return ;;
  177. esac
  178. echo "History clear"
  179. sudo apt-get autoremove #Cleanup packages
  180. echo "Clean complete"
  181. }
  182. firewall() {
  183. if [ "$#" -gt "1" ]
  184. then
  185. echo "Too many arguments. There are $#."
  186. return
  187. fi
  188. case "$1" in
  189. on)
  190. sudo iptables -F
  191. #Allows lo, allows SSH in, allows packets related to connections established with output
  192. sudo iptables -A walkin -i lo -j ACCEPT
  193. sudo iptables -A walkin -p tcp --dport 22 -j ACCEPT
  194. sudo iptables -A walkin -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
  195. #Allows lo, allows ssh out, allows connections out that are owned by root, allows vpn
  196. sudo iptables -A walkout -o lo -j ACCEPT
  197. sudo iptables -A walkout -p tcp --dport 22 -j ACCEPT
  198. sudo iptables -A walkout -m owner --uid-owner root -j ACCEPT
  199. sudo iptables -A walkout -o tun0 -j ACCEPT
  200. sudo iptables -A INPUT -j walkin
  201. sudo iptables -A INPUT -j DROP
  202. sudo iptables -A OUTPUT -j walkout
  203. sudo iptables -A OUTPUT -j DROP
  204. #Not needed
  205. sudo iptables -P INPUT DROP
  206. sudo iptables -P OUTPUT DROP
  207. echo "Firewall is on"
  208. ;;
  209. off)
  210. sudo iptables -F
  211. sudo iptables -P INPUT ACCEPT
  212. sudo iptables -P OUTPUT ACCEPT
  213. echo "Firewall is off"
  214. ;;
  215. *)
  216. echo "Invalid arguments"; return ;;
  217. esac
  218. }
  219. define() {
  220. dict $1 | less;
  221. }
  222. n () {
  223. # Block nesting of nnn in subshells
  224. if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
  225. echo "nnn is already running"
  226. return
  227. fi
  228. # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
  229. # To cd on quit only on ^G, remove the "export" as in:
  230. # NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
  231. # NOTE: NNN_TMPFILE is fixed, should not be modified
  232. NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
  233. # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
  234. # stty start undef
  235. # stty stop undef
  236. # stty lwrap undef
  237. # stty lnext undef
  238. nnn "$@"
  239. if [ -f "$NNN_TMPFILE" ]; then
  240. . "$NNN_TMPFILE"
  241. rm -f "$NNN_TMPFILE" > /dev/null
  242. fi
  243. }
  244. rebind() {
  245. sudo cp "$1" /usr/local/bin/
  246. }
  247. export GOPATH="$HOME/go"
  248. export GO111MODULE=on
  249. export EDITOR='vim'
  250. export PAGER='less'
  251. export NNN_BMS='h:~/;c:~/.config;n:~/Notes;m:/mnt/media'
  252. export NNN_FIFO=/tmp/nnn.fifo
  253. export NNN_PLUG='p:preview-tui;c:x2sel;i:imgview;s:tmspawn'
  254. export USE_PISTOL=0
  255. export XDG_CONFIG_HOME=$HOME/.config
  256. export XDG_CACHE_HOME=$HOME/.cache
  257. export XDG_DATA_HOME=$HOME/.local/share