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 "${tag:-}" ]; then
42 zwarn "tag $tag already specified, skipping: $i"
47 local file="$(date +'%F-%H%M%S')${tag:+-$tag}"
48 REPLY="${TMPDIR:-/tmp}/$file"
49 [ -n "$stdin" ] && cat >| "$REPLY"
50 sensible-editor +start "$REPLY" </dev/tty >/dev/tty
51 ln -Tsf $file ${TMPDIR:-/tmp}/${tag:-vit}
63 local target basename;
66 (????-??-??-*) target="$basename";;
67 (*) target="${(%):-"%D{%F-%H%M%S}"}-$basename";;
69 pub "${1}==${target}" 2>&1
74 [[ -f "$REPLY" ]] || vit paste
75 read -q "yesno?
\rShould I paste the file $REPLY? [yN] "
77 if [[ ${yesno:-n} == y ]]; then
78 zle -cR "pasting $REPLY …"
79 REPLY=$(pastebin "${REPLY}")
84 bindkey '\ep' _pastebinit
87 if [[ -n "$REPLY" ]]; then
88 if (( $+commands[xclip] )); then
89 echo -En "$REPLY" | xclip -in
90 zle -M "Copied to primary clipboard: $REPLY"
92 zle -M "Cannot copy to clipboard, xclip command not found"
95 zle -M "Nothing to copy, \$REPLY is empty"
99 bindkey '\ec' _copy_reply
102 local topic ts ret script
104 ts=${(%):-%D{%Y-%m-%d-%H%M}}
105 script="${TMPDIR:-/tmp}/$ts.$$.${topic:-$LOGNAME}.typescript"
107 %# " RPS1= script -qe -c "zsh -f" -f "$script"
109 zinfo "typescript is in $script ."
112 if command -v unterm >/dev/null; then
113 REPLY="${script}.txt"
114 unterm "$script" > "$REPLY"
115 zinfo "plain text transcript is in $REPLY ."