summaryrefslogtreecommitdiff
path: root/.zsh_functions
blob: d4818ec5017b3f5ac6b38496cfc84ead13d09baf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function info_print () {
    local esc_begin esc_end
    esc_begin="$1"
    esc_end="$2"
    shift 2
    printf '%s' ${esc_begin}
    printf '%s' "$*"
    printf '%s' "${esc_end}"
}

function set_title () {
    info_print  $'\e]0;' $'\a' "$@"
}

function ESC_print () {
    info_print $'\ek' $'\e\\' "$@"
}

preexec () {
  if [[ "$TERM" == screen* ]] ; then
      local CMD=${1[(wr)^(*=*|sudo|ssh|evince|-*)]}
      ESC_print ${CMD}
  fi
  case $TERM in
      (xterm*|rxvt*)
          set_title "${(%):-"%n@%m:"}" "$1"
          ;;
  esac
}

precmd () {
  if [[ $TERM == screen* ]] ; then
    ESC_print "zsh"
  fi

  case $TERM in
    (xterm*|rxvt*)
      set_title ${(%):-"%n@%m: %~"}
      ;;
  esac
}

function vifind () {
    vi $( find $1 -type f )
}

function shufflevideos () {
    find $@ -type f -iregex ".*\.\(avi\|flv\|mkv\|mpeg\|mpg\|wmv\|wva\|mp4\|webm\|wva\|m4v\|ogm\|mp4\|mov\)" -exec mpv --shuffle $MPVOPTS \{\} +
}