.mkshrc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/bin/mksh
  2. # don't run if not interactive
  3. [[ $- != *i* ]] && return
  4. # aliases
  5. . ${HOME}/.aliases
  6. alias echo='builtin print'
  7. alias type='builtin whence -v'
  8. export OPEN=${HOME}/bin/open
  9. bind '^L=clear-screen'
  10. bind '^Z=redraw'
  11. # customise your favourite editor here; the first one found is used
  12. for EDITOR in "${EDITOR:-}" vis ed vi; do
  13. EDITOR=$(\\builtin whence -p "$EDITOR") || EDITOR=
  14. [[ -n $EDITOR && -x $EDITOR ]] && break
  15. EDITOR=
  16. done
  17. # aliasing dat ls baby
  18. \\builtin alias ls=ls l='ls -F --color=auto' la='l -a' ll='l -l' lo='l -alo'
  19. \: "${HOSTNAME:=$(\\builtin ulimit -c 0; \\builtin print -r -- $(hostname \
  20. 2>/dev/null))}${EDITOR:=/bin/ed}${TERM:=vt100}${USER:=$(\\builtin ulimit \
  21. -c 0; id -un 2>/dev/null)}${USER:=?}"
  22. [[ $HOSTNAME = ?(?(ip6-)localhost?(6)) ]] && HOSTNAME=nil; \\builtin unalias ls
  23. \\builtin export EDITOR HOSTNAME TERM USER
  24. # histfile
  25. export HISTFILE=${HOME}/.hist \
  26. {SAVEHIST,HISTSIZE}=1000 \
  27. HISTCONTROL=ignoreboth
  28. ulimit -c 0
  29. # PS1
  30. HOST=`hostname`
  31. #export PS1='[${USER}@${HOST} ${PWD###*/}]$ '
  32. cd() {
  33. if [ $# -eq 0 ] ; then
  34. builtin cd ${HOME}
  35. else
  36. # lazy cd-ing functions
  37. builtin cd "$@" ||
  38. builtin cd "$@"* ||
  39. builtin cd *"$@" ||
  40. builtin cd *"$@"*
  41. #for i in 0 1 2 3 4 5 6 7 8 ; do
  42. # builtin cd $(find . -maxdepth $(($i + 1)) -mindepth $i -type d -iname "*$@" | head -n 1) && break
  43. #done
  44. fi 2> /dev/null # errors INTO THE VOID
  45. export PS1="$(_get_PS1)"
  46. }
  47. _parse_branch() {
  48. local branch=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
  49. [ -n "$branch" ] && echo -n " ($branch)"
  50. } 2> /dev/null
  51. _x="$(echo -n \\001)"
  52. _get_PS1() {
  53. case ${PWD} in
  54. ${HOME}) local tmp_pwd="~" ;;
  55. '/') local tmp_pwd="/" ;;
  56. *) local tmp_pwd="${PWD##*/}"
  57. esac
  58. case ${USER} in
  59. #noby|strlst) echo -n "$_x$(echo -n \\r)$_x\e[1;35m${USER}$_x\e[1;36m@$_x\e[1;35m${HOST}$_x \e[1;36m$tmp_pwd$_x\e[1;33m$(_parse_branch)$_x\e[1;0m " ;;
  60. noby|strlst) echo -n "$_x$(echo -n \\r)$_x\e[1;35m${USER}$_x\e[1;36m@$_x\e[1;35m${HOST}$_x \e[1;36m$tmp_pwd$_x\e[1;0m " ;;
  61. #noby) echo -n "$_x\e[1;36m $tmp_pwd$_x\e[1;33m$(_parse_branch)$_x\e[1;0m " ;;
  62. root) echo -n "[${USER}@${HOST} ${PWD###*/}]$ " ;;
  63. *) echo -n '% $tmp_pwd '
  64. esac
  65. }
  66. _get_WP() {
  67. local wpcount=$(($(ls ~/.config/walls/ | wc -l)))
  68. local rand=$((RANDOM))
  69. local wall=~/.config/walls/wall$(((($rand % $wpcount + $wpcount) % $wpcount) + 1)).png
  70. echo $wall
  71. }
  72. reroll() {
  73. feh --bg-fill $(_get_WP)
  74. }
  75. function stream() {
  76. mpv --ytdl-format=bestaudio ytdl://ytsearch:"$*"
  77. }
  78. function calc() {
  79. echo ""$*"" | bc -l
  80. }
  81. function calc() {
  82. echo "$*" | bc -l
  83. }
  84. transfer() {
  85. for i in "$@"; do
  86. finalResult="$(curl -sS -T $i https://transfer.sh/)"
  87. printf "$finalResult" | xclip -sel clip
  88. echo "uploaded!" "${finalResult}"
  89. done
  90. }
  91. shootscreentowebs() {
  92. scrot 'screenshot.jpg' -e 'mv $f /tmp/screenshot.jpg'
  93. transfer /tmp/screenshot.jpg
  94. }
  95. recency_find() {
  96. find . -maxdepth 2 -printf "%T@ %Tc %p\n" | sort -n
  97. }
  98. cd .
  99. . ${HOME}/.profile
  100. set -A complete_make -- build clean config configure obj install uninstall