bash_profile.template 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #/root/.bash_profile
  2. HISTCONTROL=ignoreboth:erasedups
  3. HISTIGNORE="q:f:v"
  4. HISTSIZE=100000
  5. HISTFILESIZE=200000
  6. shopt -s direxpand
  7. shopt -s checkhash
  8. shopt -s sourcepath
  9. shopt -s expand_aliases
  10. shopt -s autocd cdspell
  11. shopt -s extglob dotglob
  12. shopt -s no_empty_cmd_completion
  13. shopt -s autocd cdable_vars cdspell
  14. # append to the history file, don't overwrite it
  15. shopt -s histappend
  16. # multi-line commands should be stored as a single command
  17. shopt -s cmdhist
  18. shopt -s histreedit histverify
  19. # sharing of history between multiple terminals
  20. # histfile has to be read and saved after each command execution
  21. PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
  22. ls --color=al > /dev/null 2>&1 && alias ls='ls -F --color=al' || alias ls='ls -G'
  23. md () { [ $# = 1 ] && mkdir -p "$@" && cd "$@" || echo "Error - no directory passed!"; }
  24. git_branch () { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'; }
  25. HOST='\[\033[2;36m\]\h'; HOST=' '$HOST
  26. TIME='\[\033[1;31m\]\t \[\033[1;32m\]'
  27. LOCATION=' \[\033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,\}\)/\{0,1\}#\1_\2#g"`'
  28. BRANCH=' \[\033[0;33m\]$(git_branch)\[\033[00m\]\n\$ '
  29. PS1=$TIME$USER$HOST$LOCATION$BRANCH
  30. PS2='\[\033[1;36m\]>'
  31. test -f ~/.bash_aliases && . $_
  32. test -f ~/.git-completion.bash && . $_
  33. test -s ~/.autojump/etc/profile.d/autojump && . $_
  34. [ ${BASH_VERSINFO[0]} -ge 4 ] && shopt -s autocd
  35. [ -f /etc/bash_completion ] && ! shopt -oq posix && . /etc/bash_completion
  36. if test -z "${XDG_RUNTIME_DIR}"; then
  37. export XDG_RUNTIME_DIR=/tmp/${UID}-runtime-dir
  38. if ! test -d "${XDG_RUNTIME_DIR}"; then
  39. mkdir -p "${XDG_RUNTIME_DIR}"
  40. chmod 0700 "${XDG_RUNTIME_DIR}"
  41. fi
  42. fi
  43. LINES=$(stty size|cut -d" " -f1)
  44. fbecho()
  45. {
  46. [ $LINES -ge 28 ] && echo
  47. }
  48. arc()
  49. {
  50. arg="$1"; shift
  51. case $arg in
  52. -e|--extract)
  53. if [[ $1 && -e $1 ]]; then
  54. case $1 in
  55. *.tbz2|*.tar.bz2) tar xvjf "$1" ;;
  56. *.tgz|*.tar.gz) tar xvzf "$1" ;;
  57. *.tar.xz) tar xpvf "$1" ;;
  58. *.tar) tar xvf "$1" ;;
  59. *.gz) gunzip "$1" ;;
  60. *.zip) unzip "$1" ;;
  61. *.bz2) bunzip2 "$1" ;;
  62. *.7zip) 7za e "$1" ;;
  63. *.rar) unrar x "$1" ;;
  64. *) printf "'%s' can't be extracted" "$1"
  65. esac
  66. else
  67. printf "'%s' file not valid archive" "$1"
  68. fi ;;
  69. -n|--new)
  70. case $1 in
  71. *.tar.*)
  72. name="${1%.*}"
  73. ext="${1#*.tar}"; shift
  74. tar cvf "$name" "$@"
  75. case $ext in
  76. .gz) gzip -9r "$name" ;;
  77. .bz2) bzip2 -9zv "$name"
  78. esac ;;
  79. *.gz) shift; gzip -9rk "$@" ;;
  80. *.zip) zip -9r "$@" ;;
  81. *.7z) 7z a -mx9 "$@" ;;
  82. *) printf "extension non supported"
  83. esac ;;
  84. *) printf "Invalid argument '%s'" "$arg"
  85. esac
  86. }
  87. killp()
  88. {
  89. local pid name sig="-TERM" # default signal
  90. [[ $# -lt 1 || $# -gt 2 ]] && printf "Usage: killp [-SIGNAL] pattern" && return 1
  91. [[ $# -eq 2 ]] && sig=$1
  92. for pid in $(mp | awk '!/awk/ && $0~pat { print $1 }' pat=${!#}); do
  93. name=$(mp | awk '$1~var { print $5 }' var=$pid)
  94. ask "Kill process $pid <$name> with signal $sig?" && kill $sig $pid
  95. done
  96. }