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. COLORED_USERNAME=
  44. USERNAME=
  45. else
  46. COLORED_USERNAME="$USERCOLOR\u\[\033[01;33m\]@"
  47. USERNAME="\u@"
  48. fi
  49. if [ "$color_prompt" = yes ]; then
  50. PS1="${debian_chroot:+($debian_chroot)}$COLORED_USERNAME\[\033[01;32m\]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$INDICATOR "
  51. else
  52. PS1='${debian_chroot:+($debian_chroot)}'"$USERNAME"'\h:\w\$INDICATOR '
  53. fi
  54. unset color_prompt
  55. #
  56. # Aliases
  57. #
  58. # Enable color support for dir listing
  59. if [ -x /usr/bin/dircolors ]; then
  60. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  61. alias ls='ls --color=auto'
  62. alias dir='dir --color=auto'
  63. alias vdir='vdir --color=auto'
  64. alias grep='grep --color=auto'
  65. alias fgrep='fgrep --color=auto'
  66. alias egrep='egrep --color=auto'
  67. fi
  68. # ls shortcuts
  69. alias l='ls -F'
  70. alias ll='ls -AlhF'
  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. alias dc='docker compose'
  82. # git shortcuts
  83. alias gs='git status'
  84. alias gd='git diff'
  85. alias ga='git add'
  86. alias gc='git commit'
  87. alias gp='git push'
  88. alias gr='git pull --rebase'
  89. alias grr='git pull --rebase --recurse-submodules'
  90. alias m='make'
  91. # apt shortcuts
  92. alias aps='apt search'
  93. mytime () {
  94. `which time` -f %e $* > /dev/null
  95. }
  96. mkc() {
  97. mkdir -p "$@" && cd "$@"
  98. }
  99. # Run objdump on a file, open in vim with syntax highlighting
  100. dis() {
  101. if [ ! -f "$1" ]; then
  102. echo "dis: file '$1' does not exist"
  103. return
  104. fi
  105. objdump -d $1 | vim -R - "+set ft=dis"
  106. }
  107. # Add an "alert" alias for long running commands. Use like so:
  108. # sleep 10; alert
  109. 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$//'\'')"'
  110. # syntax-highlighted cat
  111. alias pcat="pygmentize -f terminal256 -O style=native -g"
  112. pless() {
  113. pcat "$@" | less -r
  114. }
  115. #
  116. # Environment
  117. #
  118. export TERM="xterm-256color"
  119. #export LC_ALL="en_US.UTF-8"
  120. #export LANG="$LC_ALL"
  121. export EDITOR=vim
  122. export PATH=$HOME/.local/bin:$PATH:/sbin:/usr/sbin
  123. #
  124. # local, installation-specific config
  125. #
  126. [ -f ~/.bashrc_local ] && . ~/.bashrc_local