bashrc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 [ "$color_prompt" = yes ]; then
  43. PS1="${debian_chroot:+($debian_chroot)}$USERCOLOR\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$INDICATOR "
  44. else
  45. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$INDICATOR '
  46. fi
  47. unset color_prompt
  48. #
  49. # Aliases
  50. #
  51. # enable color support of ls and grep
  52. if [ -x /usr/bin/dircolors ]; then
  53. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  54. alias ls='ls --color=auto'
  55. #alias dir='dir --color=auto'
  56. #alias vdir='vdir --color=auto'
  57. alias grep='grep --color=auto'
  58. alias fgrep='fgrep --color=auto'
  59. alias egrep='egrep --color=auto'
  60. fi
  61. # ls shortcuts
  62. alias ll='ls -alFh'
  63. alias la='ls -A'
  64. alias l='ls -CF'
  65. # ssh shortcuts for multivac
  66. alias smv='ssh mv -tt screen -Uxr'
  67. alias smx='ssh mvx -tt screen -Uxr'
  68. alias mvv='mosh mv -p 8051 -- screen -Uxr'
  69. # more alias fancyness
  70. alias cdhere='cd $(realpath $(pwd))'
  71. alias ocaml='rlwrap ocaml'
  72. alias c='xclip -i -selection clipboard'
  73. alias vimdiff='vim -d -c "colorscheme desert"'
  74. alias ydiff='diff -y -W 196 --left-column'
  75. alias v='gpicview'
  76. alias avg="awk '{a+=\$1} END{print a/NR}'"
  77. alias json='python -mjson.tool'
  78. alias g='grep'
  79. alias h='help'
  80. # git shortcuts
  81. alias gs='git status'
  82. alias gd='git diff'
  83. alias ga='git add'
  84. alias gc='git commit'
  85. alias gp='git push'
  86. alias gr='git pull --rebase'
  87. alias m='make'
  88. # apt shortcuts
  89. alias ag='sudo apt-get'
  90. alias aps='apt-cache search'
  91. tm () {
  92. `which time` -f %e $* > /dev/null
  93. }
  94. mkc() {
  95. mkdir -p "$@" && cd "$@"
  96. }
  97. # Add an "alert" alias for long running commands. Use like so:
  98. # sleep 10; alert
  99. 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$//'\'')"'
  100. # syntax-highlighted cat
  101. alias pcat="pygmentize -f terminal256 -O style=native -g"
  102. #
  103. # Environment
  104. #
  105. export TERM="xterm-256color"
  106. export LC_ALL="en_US.UTF-8"
  107. export LANG="$LC_ALL"
  108. export EDITOR=vim
  109. export PATH=$HOME/.local/bin:$PATH:/sbin:/usr/sbin
  110. #
  111. # local, installation-specific config
  112. #
  113. [ -f ~/.bashrc_local ] && . ~/.bashrc_local