bashrc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # ~/.bashrc: executed by bash(1) for non-login shells.
  2. #
  3. # Bash history and shell options
  4. #
  5. # if not running interactively, don't do anything
  6. [ -z "$PS1" ] && return
  7. # don't put duplicate lines or lines starting with space in the history.
  8. # See bash(1) for more options
  9. HISTCONTROL=ignoreboth
  10. # append to the history file, don't overwrite it
  11. shopt -s histappend
  12. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  13. HISTSIZE=1000
  14. HISTFILESIZE=2000
  15. # check the window size after each command and, if necessary,
  16. # update the values of LINES and COLUMNS.
  17. shopt -s checkwinsize
  18. # make less more friendly for non-text input files, see lesspipe(1)
  19. #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  20. # enable programmable completion features (you don't need to enable
  21. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  22. # sources /etc/bash.bashrc).
  23. if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
  24. . /etc/bash_completion
  25. fi
  26. #
  27. # Setting PS1
  28. #
  29. # set variable identifying the chroot you work in (used in the prompt below)
  30. if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
  31. debian_chroot=$(cat /etc/debian_chroot)
  32. fi
  33. # comment for uncolored terminal
  34. color_prompt=yes
  35. if [ $UID -eq 0 ]; then
  36. USERCOLOR="\[\e[01;31m\]" # Red if running as root
  37. INDICATOR="#"
  38. else
  39. USERCOLOR="\[\e[01;32m\]" # Green otherwise
  40. INDICATOR="$"
  41. fi
  42. if [ $USER = taddeus ]; then
  43. USERNAME=
  44. else
  45. USERNAME="\u@"
  46. fi
  47. if [ "$color_prompt" = yes ]; then
  48. PS1="${debian_chroot:+($debian_chroot)}$USERCOLOR$USERNAME\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$INDICATOR "
  49. else
  50. PS1='${debian_chroot:+($debian_chroot)}'"$USERNAME"'\h:\w\$INDICATOR '
  51. fi
  52. unset color_prompt
  53. #
  54. # Aliases
  55. #
  56. # enable color support of ls and grep
  57. if [ -x /usr/bin/dircolors ]; then
  58. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  59. export LS_OPTIONS="--color=auto"
  60. #alias ls='ls --color=auto'
  61. #alias dir='dir --color=auto'
  62. #alias vdir='vdir --color=auto'
  63. alias grep='grep --color=auto'
  64. alias fgrep='fgrep --color=auto'
  65. alias egrep='egrep --color=auto'
  66. fi
  67. # ls shortcuts
  68. alias ll='ls -alFh'
  69. alias la='ls -A'
  70. alias l='ls -lFh'
  71. # ssh shortcuts for multivac
  72. alias mvv='mosh mv -p 8051 -- screen -Uxr'
  73. # more alias fancyness
  74. alias cdhere='cd $(realpath $(pwd))'
  75. alias vimdiff='vim -d -c "colorscheme desert"'
  76. alias ydiff='diff -y -W 196 --left-column'
  77. alias avg="awk '{a+=\$1} END{print a/NR}'"
  78. alias json='python -mjson.tool'
  79. alias g='grep'
  80. alias h='help'
  81. # git shortcuts
  82. alias gs='git status'
  83. alias gd='git diff'
  84. alias ga='git add'
  85. alias gc='git commit'
  86. alias gp='git push'
  87. alias gr='git pull --rebase'
  88. alias grr='git pull --rebase --recurse-submodules'
  89. alias m='make'
  90. # apt shortcuts
  91. alias aps='apt search'
  92. mytime () {
  93. `which time` -f %e $* > /dev/null
  94. }
  95. mkc() {
  96. mkdir -p "$@" && cd "$@"
  97. }
  98. # Run objdump on a file, open in vim with syntax highlighting
  99. dis() {
  100. if [ ! -f "$1" ]; then
  101. echo "dis: file '$1' does not exist"
  102. return
  103. fi
  104. objdump -d $1 | vim -R - "+set ft=dis"
  105. }
  106. # Add an "alert" alias for long running commands. Use like so:
  107. # sleep 10; alert
  108. alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
  109. # syntax-highlighted cat
  110. alias pcat="pygmentize -f terminal256 -O style=native -g"
  111. pless() {
  112. pcat "$@" | less -r
  113. }
  114. #
  115. # Environment
  116. #
  117. export TERM="xterm-256color"
  118. #export LC_ALL="en_US.UTF-8"
  119. #export LANG="$LC_ALL"
  120. export EDITOR=vim
  121. export PATH=$HOME/.local/bin:$PATH:/sbin:/usr/sbin
  122. #
  123. # local, installation-specific config
  124. #
  125. [ -f ~/.bashrc_local ] && . ~/.bashrc_local