Guest User

Untitled

a guest
Jun 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. #!/bin/mksh
  2. [ -z "$PS1" ] && return
  3.  
  4. # {{{ prompt
  5. # {{{ is_scm_dir
  6. is_scm_dir()
  7. {
  8. if [ -d $2/.$1 ]; then
  9. return 0
  10. elif [ $2 == "/" ]; then
  11. return 1
  12. fi
  13. is_scm_dir $1 $(dirname $2)
  14. return $?
  15. }
  16. # }}}
  17. # {{{ scm_branch
  18. scm_branch()
  19. {
  20. if is_scm_dir git $(pwd); then
  21. branch=$(git branch | grep -e '^\*' | cut -d ' ' -f 2)
  22. echo "(git)(${branch}) "
  23. return 0
  24. fi
  25.  
  26. if is_scm_dir hg $(pwd); then
  27. branch=$(hg branch)
  28. echo "(hg)(${branch}) "
  29. return 0
  30. fi
  31.  
  32. if is_scm_dir svn $(pwd); then
  33. branch=$(svn info | grep ^Rev | cut -d' ' -f2)
  34. echo "(svn)(${branch}) "
  35. return 0
  36. fi
  37.  
  38. if is_scm_dir bzr $(pwd) ; then
  39. branch=$(bzr log | grep '^rev' | head -n1 | cut -d' ' -f2)
  40. echo "(bzr)(${branch}) "
  41. return 0
  42. fi
  43. return 1
  44. }
  45. # }}}
  46. # {{{ neatpwd
  47. function neatpwd {
  48. typeset d=${PWD:-?} n p=~;
  49. [[ $p = ?(*/) ]] || d=${d/#$p/~}
  50. (( ${#d} > (n = (COLUMNS/3 < 7 ? 7 : COLUMNS/3)) )) && {
  51. d=${d:(-n)};
  52. p=...;
  53. } || p=;
  54. print -nr -- "$p$d"
  55. }
  56. # }}}
  57. # {{{ color
  58. function color {
  59. echo -n "\e[$1;${2}m"
  60. shift 2
  61. echo "$@\e[00m"
  62. }
  63. # }}}
  64. PS1='$(color 01 33 "(`date +%H:%M:%S`)") $(color 01 34 `neatpwd`) $(color 01 30 `scm_branch`)'
  65. if (( USER_ID )); then
  66. PS1="$PS1$ "
  67. else
  68. PS1="$PS1# "
  69. fi
  70. # }}}
  71.  
  72. # {{{ aliases
  73. alias ls='ls --color=auto'
  74. alias la='ls -a'
  75. alias ll='ls -lh'
  76.  
  77. alias rm='rm -rf'
  78. alias rcp='rsync -r --size-only --progress'
  79. alias vi='vim'
  80. alias less='less -r'
  81. alias ..='cd ..'
  82. alias cdrecord='cdrecord -verbose'
  83. alias gently='nice -n 20 ionice -c 3'
  84. # }}}
  85.  
  86. # {{{ history
  87. export HISTSIZE=200000
  88. export HISTFILE=~/.history
  89. # }}}
  90.  
  91. # {{{ env vars
  92. PATH=/usr/lib/ccache/bin:${HOME}/bin:${PATH}
  93. PATH=${PATH}:/usr/sbin
  94. export PATH=${PATH}:/usr/local/games:/sbin
  95.  
  96. export BROWSER=$HOME/bin/mimehandler
  97. export EDITOR=vim
  98.  
  99. # export LC_ALL=de_DE.UTF-8
  100. # export LC_CTYPE=de_DE.UTF-8
  101. export LANG=de_DE.UTF-8
  102.  
  103. export DOOMWADDIR=~/.zdoom
  104. export LUA_PATH="${HOME}/.lua/?.lua;$(strings /usr/lib/liblua.so | grep init.lua)"
  105.  
  106. export GOROOT=~/sourcecode/go
  107. export GOBIN=~/bin
  108. export GOOS=linux
  109. export GOARCH=386
  110.  
  111. export GTK2_RC_FILES="/home/gregor/.gtkrc.mine"
  112. export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
  113. # }}}
  114.  
  115. # {{{ window size change handler
  116. function update_winsize {
  117. export COLUMNS=`stty -a | grep -oe 'columns [0-9]\+' | cut -d' ' -f2`
  118. export ROWS=`stty -a | grep -oe 'rows [0-9]\+' | cut -d' ' -f2`
  119. }
  120. trap update_winsize 28 # 28 is SIGWINCH
  121. update_winsize
  122. # }}}
Add Comment
Please, Sign In to add comment