All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 # Helper functions for temporary files, directories, and pastebining
4 # Copyright © 1994–2017 martin f. krafft <madduck@madduck.net>
5 # Released under the terms of the Artistic Licence 2.0
7 # Source repository: http://git.madduck.net/v/etc/zsh.git
12 local dirname="$(date +'%F-%H%M%S')${1:+-$1}"
13 REPLY="${TMPDIR:-/tmp}/$dirname"
15 if [[ -n "$1" ]]; then
16 local link="${TMPDIR:-/tmp}/${1:-cdt}"
17 ln -Tnsf "$dirname" "$link"
38 -) local stdin=1; shift;;
39 .*) if [ -z "${ft:-}" ]; then
42 zwarn "filetype $ft already specified, skipping: ${i#.}"
45 *) if [ -z "${tag:-}" ]; then
48 zwarn "tag $tag already specified, skipping: $i"
53 local file="$(date +'%F-%H%M%S')${tag:+-$tag}"
54 REPLY="${TMPDIR:-/tmp}/$file"
55 [ -n "$stdin" ] && cat >| "$REPLY"
56 sensible-editor +start "$REPLY" </dev/tty >/dev/tty
57 ln -Tsf $file ${TMPDIR:-/tmp}/${tag:-vit}
69 local target basename;
72 (????-??-??-*) target="$basename";;
73 (*) target="${(%):-"%D{%F-%H%M%S}"}-$basename";;
75 pub "${1}==${target}" 2>&1
80 [[ -f "$REPLY" ]] || vit paste
81 read -q "yesno?
\rShould I paste the file $REPLY? [yN] "
83 if [[ ${yesno:-n} == y ]]; then
84 zle -cR "pasting $REPLY …"
85 REPLY=$(pastebin "${REPLY}")
90 bindkey '\ep' _pastebinit
93 if [[ -n "$REPLY" ]]; then
94 if (( $+commands[xclip] )); then
95 echo -En "$REPLY" | xclip -in
96 zle -M "Copied to primary clipboard: $REPLY"
98 zle -M "Cannot copy to clipboard, xclip command not found"
101 zle -M "Nothing to copy, \$REPLY is empty"
105 bindkey '\ec' _copy_reply
108 local topic ts ret script
110 ts=${(%):-%D{%Y-%m-%d-%H%M}}
111 script="${TMPDIR:-/tmp}/$ts.$$.${topic:-$LOGNAME}.typescript"
113 %# " RPS1= script -qe -c "zsh -f" -f "$script"
115 zinfo "typescript is in $script ."
118 if command -v unterm >/dev/null; then
119 REPLY="${script}.txt"
120 unterm "$script" > "$REPLY"
121 zinfo "plain text transcript is in $REPLY ."