summaryrefslogtreecommitdiff
path: root/.zsh_functions
blob: ed0cddc6bdb960531bb76ec086eedf0a52911827 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#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
#
##    local INBOXINFO="$(task rc.gc=off rc.verbose=nothing +in +PENDING count) "
#
#    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 $@)
}

function new_haskell_project () {
    stack new $1 simple
    cd $1
    git init
}

function henkspngpostproc () {
    local resize_by
    local img
    resize_by="$1"
    shift
    echo "Creating Directories …"
    mkdir --parents resized/pngnqed/optipnged optimized
    for img in $*
    do
        echo "Resizing image …"
        convert -resize $resize_by% "$img" "resized/$img"
        echo "Running pngnq …"
        pngnq -s1 -f -d "resized/pngnqed" -e .png "resized/$img"
        echo "Running optipng …"
        optipng -force -out "resized/pngnqed/optipnged/$img" "resized/pngnqed/$img"
        echo "Moving final image to directory 'optimized' …"
        cp --verbose --interactive --target-directory=optimized/ "resized/pngnqed/optipnged/$img"
        echo "Removing temporary images …"
        #rm --verbose --interactive \
        rm --verbose \
          "resized/$img" \
          "resized/pngnqed/$img" \
          "resized/pngnqed/optipnged/$img"
    done
    rmdir --parents resized/pngnqed/optipnged
}

function with () {
    local prefix="$* " str compcontext=normal:normal:_normal
    while :
    do
      str=$prefix
      vared str && eval $str
    done
}

function stardewpause () {
  while read bar
  do
    xdotool \
      search --class 'StardewValley' \
      windowactivate --sync \
      type --delay 100 t/pause
  done
}