dot_bashrc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. #!/bin/bash
  2. # ~/.bashrc: executed by bash(1) for non-login shells.
  3. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
  4. # for examples
  5. # If not running interactively, don't do anything
  6. case $- in
  7. *i*) ;;
  8. *) return;;
  9. esac
  10. # don't put duplicate lines or lines starting with space in the history.
  11. # See bash(1) for more options
  12. HISTCONTROL=ignoreboth
  13. # append to the history file, don't overwrite it
  14. shopt -s histappend
  15. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  16. HISTSIZE=10000
  17. HISTFILESIZE=200000
  18. # check the window size after each command and, if necessary,
  19. # update the values of LINES and COLUMNS.
  20. shopt -s checkwinsize
  21. # If set, the pattern "**" used in a pathname expansion context will
  22. # match all files and zero or more directories and subdirectories.
  23. #shopt -s globstar
  24. # make less more friendly for non-text input files, see lesspipe(1)
  25. #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  26. # set variable identifying the chroot you work in (used in the prompt below)
  27. if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
  28. debian_chroot=$(cat /etc/debian_chroot)
  29. fi
  30. # set a fancy prompt (non-color, unless we know we "want" color)
  31. case "$TERM" in
  32. xterm-color|*-256color) color_prompt=yes;;
  33. esac
  34. # uncomment for a colored prompt, if the terminal has the capability; turned
  35. # off by default to not distract the user: the focus in a terminal window
  36. # should be on the output of commands, not on the prompt
  37. #force_color_prompt=yes
  38. if [ -n "$force_color_prompt" ]; then
  39. if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  40. # We have color support; assume it's compliant with Ecma-48
  41. # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  42. # a case would tend to support setf rather than setaf.)
  43. color_prompt=yes
  44. else
  45. color_prompt=
  46. fi
  47. fi
  48. if [ "$color_prompt" = yes ]; then
  49. PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  50. else
  51. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  52. fi
  53. unset color_prompt force_color_prompt
  54. # If this is an xterm set the title to user@host:dir
  55. case "$TERM" in
  56. xterm*|rxvt*)
  57. PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  58. ;;
  59. *)
  60. ;;
  61. esac
  62. # enable color support of ls and also add handy aliases
  63. if [ -x /usr/bin/dircolors ]; then
  64. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  65. alias ls='ls --color=auto'
  66. #alias dir='dir --color=auto'
  67. #alias vdir='vdir --color=auto'
  68. #alias grep='grep --color=auto'
  69. #alias fgrep='fgrep --color=auto'
  70. #alias egrep='egrep --color=auto'
  71. fi
  72. # colored GCC warnings and errors
  73. #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
  74. # some more ls aliases
  75. #alias ll='ls -l'
  76. #alias la='ls -A'
  77. #alias l='ls -CF'
  78. # Alias definitions.
  79. # You may want to put all your additions into a separate file like
  80. # ~/.bash_aliases, instead of adding them here directly.
  81. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  82. if [ -f ~/.bash_aliases ]; then
  83. . ~/.bash_aliases
  84. fi
  85. if [ "$(hostname -f)" == "ralf-21kscto1ww" ]; then
  86. export SSH_AUTH_SOCK="$HOME/.bitwarden-ssh-agent.sock"
  87. fi
  88. # if user is not root, pass all commands via sudo #
  89. if [ $UID -ne 0 ]; then
  90. alias pacman='sudo pacman'
  91. alias reboot='sudo reboot'
  92. alias update='sudo apt-get upgrade'
  93. alias apt-get="sudo apt-get"
  94. alias updatey="sudo apt-get --yes"
  95. # update on one command
  96. alias update='sudo apt-get update && sudo apt-get upgrade'
  97. fi
  98. ## cd specific
  99. ## get rid of command not found ##
  100. alias cd..='cd ..'
  101. ## a quick way to get out of current directory ##
  102. alias ..='cd ..'
  103. alias ...='cd ../../../'
  104. alias ....='cd ../../../../'
  105. alias .....='cd ../../../../'
  106. alias .4='cd ../../../../'
  107. alias .5='cd ../../../../..'
  108. ## Colorize the grep command output for ease of use (good for log files)##
  109. alias grep='grep --color=auto'
  110. alias egrep='egrep --color=auto'
  111. alias fgrep='fgrep --color=auto'
  112. # Generate sha1 digest
  113. alias sha1='openssl sha1'
  114. # Create parent directories on demand
  115. alias mkdir='mkdir -pv'
  116. # Make mount command output pretty and human readable format
  117. # alias mount='mount |column -t'
  118. #
  119. # Command short cuts to save time
  120. alias h='history'
  121. alias j='jobs -l'
  122. # Create a new set of commands
  123. alias path='echo -e ${PATH//:/\\n}'
  124. alias now='date +"%T"'
  125. alias nowtime=now
  126. alias nowdate='date +"%d-%m-%Y"'
  127. # Set vim as default
  128. alias vi=nvim
  129. # alias svi='sudo vi'
  130. # alias vis='vim "+set si"'
  131. # alias edit='vim'
  132. # Control output of networking tool called ping
  133. # Stop after sending count ECHO_REQUEST packets #
  134. alias ping='ping -c 5'
  135. # Do not wait interval 1 second, go fast #
  136. alias fastping='ping -c 100 -s.2'
  137. # Show open ports
  138. # Use netstat command to quickly list all TCP/UDP port on the server:
  139. alias ports='netstat -tulanp'
  140. # Add safety nets
  141. # do not delete / or prompt if deleting more than 3 files at a time #
  142. alias rm='rm -I --preserve-root'
  143. # confirmation
  144. alias mv='mv -i'
  145. alias cp='cp -i'
  146. alias ln='ln -i'
  147. # Parenting changing perms on / #
  148. alias chown='chown --preserve-root'
  149. alias chmod='chmod --preserve-root'
  150. alias chgrp='chgrp --preserve-root'
  151. # Get system memory, cpu usage, and gpu memory info quickly
  152. # # pass options to free ##
  153. # alias meminfo='free -m -l -t'
  154. # # get top process eating memory
  155. # alias psmem='ps auxf | sort -nr -k 4'
  156. # alias psmem10='ps auxf | sort -nr -k 4 | head -10'
  157. # # get top process eating cpu ##
  158. # alias pscpu='ps auxf | sort -nr -k 3'
  159. # alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
  160. # # Get server cpu info ##
  161. # alias cpuinfo='lscpu'
  162. # # older system use /proc/cpuinfo ##
  163. ##alias cpuinfo='less /proc/cpuinfo' ##
  164. # # get GPU ram on desktop / laptop##
  165. # alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'
  166. echo "pwd: $(pwd)"
  167. bashrcDir="$HOME/.bashrc.d"
  168. echo "bashrcDir: '$bashrcDir'"
  169. if [ -d "$bashrcDir" ]; then
  170. for ext in $bashrcDir/*sh; do
  171. if [ -f "ext" ]; then
  172. echo include "$ext"
  173. . $ext
  174. fi
  175. done
  176. else
  177. echo "bashrcDir: '$bashrcDir' NOT FOUND!"
  178. ls -l $bashrcDir
  179. fi