.kshrc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. bold=''
  2. cyan=''
  3. green=''
  4. red=''
  5. reset=''
  6. reverse=''
  7. white=''
  8. yellow=''
  9. PS1='$(date +%R) \[$bold$([ $? -eq 0 ] && print $white || print $red)\]$? \[$reset$cyan\]\w \[$reset\]\$ '
  10. HISTFILE=~/.ksh_history
  11. HISTSIZE=10000
  12. HISTCONTROL=ignoredups:ignorespace
  13. set -C
  14. set -o vi
  15. # overly complex but fun
  16. for _d in /var/log /usr/{include,obj,ports,rfc,src,www,xenocara}; do
  17. _a=${_d##*/}
  18. alias -d ${_a%${_a#?}}=${_d}
  19. done
  20. alias ....='cd ../../../'
  21. alias ...='cd ../../'
  22. alias ..='cd ../'
  23. alias c='cvs -z7'
  24. alias d='doas '
  25. alias df='df -k'
  26. alias du='du -k'
  27. alias e='exec '
  28. alias frg='rg -F'
  29. alias g=git
  30. alias hup='pkill -HUP'
  31. alias ic=ifconfig
  32. alias igrep='grep -i'
  33. alias j=jobs
  34. alias k='exec ksh -l'
  35. alias la='ls -a'
  36. alias le='less -FcmNqX --follow-name'
  37. alias ll='ls -lAFh'
  38. alias ls='ls -F'
  39. alias m=man
  40. alias mk=make
  41. alias mv='mv -i'
  42. alias o='fg %-'
  43. alias oc='c -d cvs:/cvs'
  44. alias pa=pkg_add
  45. alias pd=pkg_delete
  46. alias pi=pkg_info
  47. alias pl=pkg_locate
  48. alias portsql='sqlite3 /usr/local/share/sqlports'
  49. alias pwadd='spm add'
  50. pwcp() {
  51. # copy password and clear primary selection after pasting
  52. spm show "${1}" |
  53. tr -d \\n |
  54. xclip -i -selection primary -loops 1 -quiet |
  55. 2> /dev/null
  56. }
  57. alias pwdel='spm del'
  58. alias pwget='spm show'
  59. alias pwls='spm list'
  60. alias pwrnd='pwgen -C -n -s -y 42 1 | spm add'
  61. alias pwsearch='spm search'
  62. alias rm='rm -i'
  63. alias s=ssh
  64. alias time='time '
  65. alias t=tmux
  66. alias v=vise
  67. alias wl=wireless
  68. alias ytdl=youtube-dl
  69. # is $1 missing from $2 (or PATH) ?
  70. function no_path {
  71. eval _v="\$${2:-PATH}"
  72. case :$_v: in
  73. *:${1%%/}:*) return 1;; # no we have it
  74. esac
  75. }
  76. # if $1 exists and is not in path, append it
  77. function add_path {
  78. [[ -d ${1%%/} ]] && no_path "$@" && eval ${2:-PATH}=\"\$${2:-PATH}:${1%%/}\"
  79. }
  80. # if $1 exists and is not in path, prepend it
  81. function pre_path {
  82. [[ -d ${1%%/} ]] && no_path "$@" && eval ${2:-PATH}=\"${1%%/}:\$${2:-PATH}\"
  83. }
  84. # if $1 is in path, remove it
  85. function del_path {
  86. no_path "${1%%/}" || eval ${2:-PATH}=\"$(eval echo :\$${2:-PATH}: |
  87. sed -e "s,:${1%%/}:,:," -e "s,^:,," -e "s,:\$,,")\"
  88. }
  89. alias .p=". ~/.p.sh"