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"
39 -) local stdin=1; shift;;
40 .*) if [ -z "${ft:-}" ]; then
43 zwarn "filetype $ft already specified, skipping: ${i#.}"
46 *) if [ -z "${tag:-}" ]; then
49 zwarn "tag $tag already specified, skipping: $i"
54 local file="$(date +'%F-%H%M%S')${tag:+-$tag}"
55 REPLY="${TMPDIR:-/tmp}/$file"
56 [ -n "$stdin" ] && cat >| "$REPLY"
57 sensible-editor +start "$REPLY" </dev/tty >/dev/tty
58 ln -Tsf $file ${TMPDIR:-/tmp}/${tag:-vit}
60 print -s sensible-editor "$REPLY"
71 local target basename;
74 (????-??-??-*) target="$basename";;
75 (*) target="${(%):-"%D{%F-%H%M%S}"}-$basename";;
77 pub "${1}==${target}" 2>&1
82 [[ -f "$REPLY" ]] || vit paste
83 read -q "yesno?
\rShould I paste the file $REPLY? [yN] "
85 if [[ ${yesno:-n} == y ]]; then
86 zle -cR "pasting $REPLY …"
87 REPLY=$(pastebin "${REPLY}")
92 bindkey '\ep' _pastebinit
95 if [[ -n "$REPLY" ]]; then
96 if (( $+commands[xclip] )); then
97 echo -En "$REPLY" | xclip -in
98 zle -M "Copied to primary clipboard: $REPLY"
100 zle -M "Cannot copy to clipboard, xclip command not found"
103 zle -M "Nothing to copy, \$REPLY is empty"
107 bindkey '\ec' _copy_reply
110 local topic ts ret script
112 ts=${(%):-%D{%Y-%m-%d-%H%M}}
113 script="${TMPDIR:-/tmp}/$ts.$$.${topic:-$LOGNAME}.typescript"
115 %# " RPS1= script -qe -c "zsh -f" -f "$script"
117 zinfo "typescript is in $script ."
120 if command -v unterm >/dev/null; then
121 REPLY="${script}.txt"
122 unterm "$script" > "$REPLY"
123 zinfo "plain text transcript is in $REPLY ."