summaryrefslogtreecommitdiff
path: root/.zsh_functions
blob: 664e266803ed3bb0c09e9689e67ecd0979b041cb (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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 () {
    case $TERM in
        (xterm*|rxvt*)
            set_title "${(%):-"%n@%m:"}" "$1"
        ;;
        (screen*)
            local CMD=${1[(wr)^(*=*|sudo|ssh|evince|-*)]}
            ESC_print ${CMD}
        ;;
    esac
}

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

    vcs_info

    PS1="${HENKSPROMPTHEADER}%(0?..%F{red}E%?%f )%(1j.%F{yellow}J%j%f .)%(3L.%F{yellow}L%L%f .)%3~ %F{green}$VCSH_REPO_NAME%f%F{yellow}${vcs_info_msg_0_}%f%# "
}

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

function mpvshuffledir () {
    mpv $MPVOPTS \
        --shuffle \
        ${1:-.}/**/*.(mpeg|webm|avi|flv|mkv|mpg|wmv|wva|mp4|wva|m4v|ogm|mp4|mov)
}

function movies_oldest () {
    mpv $MPVOPTS \
        **/*.(mpeg|webm|avi|flv|mkv|mpg|wmv|wva|mp4|wva|m4v|ogm|mp4|mov)(Om)
}

function movies_newest () {
    mpv $MPVOPTS \
        **/*.(mpeg|webm|avi|flv|mkv|mpg|wmv|wva|mp4|wva|m4v|ogm|mp4|mov)(om)
}

function movies_smallest () {
    mpv $MPVOPTS \
        **/*.(mpeg|webm|avi|flv|mkv|mpg|wmv|wva|mp4|wva|m4v|ogm|mp4|mov)(oL)
}

function movies_biggest () {
    mpv $MPVOPTS \
        **/*.(mpeg|webm|avi|flv|mkv|mpg|wmv|wva|mp4|wva|m4v|ogm|mp4|mov)(OL)
}