summaryrefslogtreecommitdiff
path: root/Functions
diff options
context:
space:
mode:
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Calendar/after67
-rw-r--r--Functions/Calendar/before67
-rw-r--r--Functions/Calendar/calendar4
-rw-r--r--Functions/Misc/run-help-ip42
-rw-r--r--Functions/Misc/tetriscurses386
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_git18
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_hg17
-rw-r--r--Functions/VCS_Info/VCS_INFO_quilt30
-rw-r--r--Functions/VCS_Info/vcs_info1
-rw-r--r--Functions/Zftp/zfcd_match8
-rw-r--r--Functions/Zftp/zfcget11
-rw-r--r--Functions/Zftp/zfcput10
-rw-r--r--Functions/Zftp/zffcache5
-rw-r--r--Functions/Zftp/zfget_match9
-rw-r--r--Functions/Zftp/zfrglob15
-rw-r--r--Functions/Zftp/zftransfer9
-rw-r--r--Functions/Zftp/zftype6
-rw-r--r--Functions/Zftp/zfuget15
-rw-r--r--Functions/Zftp/zfuput15
-rw-r--r--Functions/Zle/edit-command-line12
20 files changed, 664 insertions, 83 deletions
diff --git a/Functions/Calendar/after b/Functions/Calendar/after
new file mode 100644
index 000000000..7fb0166f7
--- /dev/null
+++ b/Functions/Calendar/after
@@ -0,0 +1,67 @@
+# Glob qualifier function, e.g
+#
+# print *(e:after 2014/08/01:)
+# print *(e-after today:12:00-)
+#
+# If named before:
+# Match files modified before a given time.
+#
+# If named after:
+# Match files modified after a given time. Use as glob qualifier.
+# N.B.: "after" actually includes the given time as it is to second
+# precision (it would be inconvenient to exclude the first second of a date).
+# It should therefore more logically be called "from", but that's a less
+# obvious name.
+#
+# File to test is in $REPLY.
+#
+# Similar to age, but only takes at most one data, which is
+# compared directly with the current time.
+
+emulate -L zsh
+
+zmodload -F zsh/stat b:zstat
+zmodload -i zsh/parameter
+
+autoload -Uz calendar_scandate
+
+local timefmt
+local -a vals tmp
+
+[[ -e $REPLY ]] || return 1
+zstat -A vals +mtime -- $REPLY || return 1
+
+if (( $# == 1 )); then
+ if [[ $1 = :* ]]; then
+ timefmt="%Y/%m/%d:%H:%M:%S"
+ zstat -A tmp -F $timefmt +mtime -- ${1#:} || return 1
+ local AGEREF=$tmp[1]
+ else
+ local AGEREF=$1
+ fi
+fi
+
+integer mtime=$vals[1] date1 date2
+local REPLY REPLY2
+
+# allow a time only (meaning today)
+if calendar_scandate -t $AGEREF; then
+ date1=$REPLY
+
+ case $0 in
+ (after)
+ (( mtime >= date1 ))
+ ;;
+
+ (before)
+ (( mtime < date1 ))
+ ;;
+
+ (*)
+ print "$0: must be named 'after' or 'before'" >&2
+ return 1
+ ;;
+ esac
+else
+ return 1
+fi
diff --git a/Functions/Calendar/before b/Functions/Calendar/before
new file mode 100644
index 000000000..7fb0166f7
--- /dev/null
+++ b/Functions/Calendar/before
@@ -0,0 +1,67 @@
+# Glob qualifier function, e.g
+#
+# print *(e:after 2014/08/01:)
+# print *(e-after today:12:00-)
+#
+# If named before:
+# Match files modified before a given time.
+#
+# If named after:
+# Match files modified after a given time. Use as glob qualifier.
+# N.B.: "after" actually includes the given time as it is to second
+# precision (it would be inconvenient to exclude the first second of a date).
+# It should therefore more logically be called "from", but that's a less
+# obvious name.
+#
+# File to test is in $REPLY.
+#
+# Similar to age, but only takes at most one data, which is
+# compared directly with the current time.
+
+emulate -L zsh
+
+zmodload -F zsh/stat b:zstat
+zmodload -i zsh/parameter
+
+autoload -Uz calendar_scandate
+
+local timefmt
+local -a vals tmp
+
+[[ -e $REPLY ]] || return 1
+zstat -A vals +mtime -- $REPLY || return 1
+
+if (( $# == 1 )); then
+ if [[ $1 = :* ]]; then
+ timefmt="%Y/%m/%d:%H:%M:%S"
+ zstat -A tmp -F $timefmt +mtime -- ${1#:} || return 1
+ local AGEREF=$tmp[1]
+ else
+ local AGEREF=$1
+ fi
+fi
+
+integer mtime=$vals[1] date1 date2
+local REPLY REPLY2
+
+# allow a time only (meaning today)
+if calendar_scandate -t $AGEREF; then
+ date1=$REPLY
+
+ case $0 in
+ (after)
+ (( mtime >= date1 ))
+ ;;
+
+ (before)
+ (( mtime < date1 ))
+ ;;
+
+ (*)
+ print "$0: must be named 'after' or 'before'" >&2
+ return 1
+ ;;
+ esac
+else
+ return 1
+fi
diff --git a/Functions/Calendar/calendar b/Functions/Calendar/calendar
index 00f59981c..aff39b369 100644
--- a/Functions/Calendar/calendar
+++ b/Functions/Calendar/calendar
@@ -12,6 +12,7 @@ local -A reply
zmodload -i zsh/datetime || return 1
zmodload -i zsh/zutil || return 1
+zmodload -F zsh/files b:zf_ln || return 1
autoload -Uz calendar_{add,parse,read,scandate,show,lockfiles}
@@ -254,8 +255,7 @@ if (( verbose )); then
fi
local mycmds="${TMPPREFIX:-/tmp/zsh}.calendar_cmds.$$"
-touch $mycmds
-chmod 600 $mycmds
+zf_ln -fn =(<<<'') $mycmds || return 1
# start of subshell for OS file locking
(
diff --git a/Functions/Misc/run-help-ip b/Functions/Misc/run-help-ip
new file mode 100644
index 000000000..3f15b01fb
--- /dev/null
+++ b/Functions/Misc/run-help-ip
@@ -0,0 +1,42 @@
+#! zsh -f
+#
+# Install this function by placing it in your FPATH and then
+# adding to your .zshrc the line if you use run-help function:
+# autoload -Uz run-help-ip
+
+if [ $# -eq 0 ]; then
+ man ip
+ return
+fi
+
+if ! man -w ip-address >/dev/null 2>&1; then
+ man ip
+ return
+fi
+
+while [[ $# != 0 && $1 == -* ]]; do
+ shift
+done
+
+case $1 in
+ (addr*) man ip-address ;;
+ (addrlabel) man ip-addrlabel ;;
+ (l2*) man ip-l2tp ;;
+ (li*) man ip-link ;;
+ (ma*) man ip-maddress ;;
+ (mo*) man ip-monitor ;;
+ (mr*) man ip-mroute ;;
+ (nei*) man ip-neighbour ;;
+ (netc*) man ip-netconf ;;
+ (netn*) man ip-netns ;;
+ (nt*) man ip-ntable ;;
+ (ro*) man ip-route ;;
+ (ru*) man ip-rule ;;
+ (tcp*) man ip-tcp_metrics ;;
+ (to*) man ip-token ;;
+ (tu*) man ip-tunnel ;;
+ (xf*) man ip-xfrm ;;
+ (*) man ip ;;
+esac
+
+return $?
diff --git a/Functions/Misc/tetriscurses b/Functions/Misc/tetriscurses
new file mode 100644
index 000000000..371456082
--- /dev/null
+++ b/Functions/Misc/tetriscurses
@@ -0,0 +1,386 @@
+# I noticed we don't ship any contrib and/or example scripts using the
+# zcurses module, and also that the builtin tetris is sort of boring, so
+# I figured I'd port it to curses. It works pretty well, but I noticed
+# two problems with the zcurses module in the process:
+#
+# 1. the HAVE_USE_DEFAULT_COLORS define seems to never be defined?
+#
+# 2a. resizing the window causes 'zcurses input' to wait forever for a
+# key, even with a timeout defined.
+#
+# Bart says:
+# >This probably has something to do with the special-casing around wgetch()
+# >for signals handled by the "trap" command. See the big comment in
+# >Src/Modules/curses.c lines 1073-1103.
+#
+# >It may be problematic to mix curses with the generic signal handling in
+# >the main shell. We may need to swap in a SIGWINCH handler wrapper while
+# >the curses UI is active, and restore the main handler when leaving it.
+#
+# 2b. resizing the window doesn't cause an event while running the
+# program, but if i resize before starting(?) i get an event RESIZE on
+# my first input call.
+#
+# Bart says:
+# >There's probably some state that needs to be cleared on entry to
+# >zccmd_input() so that curses doesn't see something left over from the
+# >previous signal. Unfortunately I don't know what that would be.
+
+if (( $LINES < 22 || $COLUMNS < 46 )); then
+ echo >&2 'terminal needs to be at least 22 lines and 46 columns'
+ return
+fi
+
+emulate -L zsh
+
+typeset -a tetris_shapes
+tetris_shapes=(
+ 0x0f00 0x4444 0x0f00 0x4444
+ 0x4e00 0x4c40 0x0e40 0x4640
+ 0x6600 0x6600 0x6600 0x6600
+ 0x4620 0x6c00 0x4620 0x6c00
+ 0x2640 0x6300 0x2640 0x6300
+ 0x6440 0x8e00 0x44c0 0x0e20
+ 0xc440 0x0e80 0x4460 0x2e00
+)
+typeset -A tetris_rotations
+tetris_rotations=(
+ 0x0f00 0x4444 0x4444 0x0f00
+ 0x4e00 0x4c40 0x4c40 0x0e40 0x0e40 0x4640 0x4640 0x4e00
+ 0x6600 0x6600
+ 0x4620 0x6c00 0x6c00 0x4620
+ 0x2640 0x6300 0x6300 0x2640
+ 0x6440 0x8e00 0x8e00 0x44c0 0x44c0 0x0e20 0x0e20 0x6440
+ 0xc440 0x0e80 0x0e80 0x4460 0x4460 0x2e00 0x2e00 0xc440
+)
+local tetris_vsz=20 tetris_hsz=11
+local tetris_blankline=${(l:11:: :)}
+local tetris_blankboard=${(j::):-${(l:11:: :)}${(s: :)^${(l:20:: :)}}}
+
+local tetris_board=$tetris_blankboard
+local tetris_score=0
+local tetris_lines=0
+
+local tetris_{block{,_next,_x,_y},i}
+
+function __tetris-next-block {
+ tetris_block_next=$tetris_shapes[1+RANDOM%$#tetris_shapes]
+}
+
+function __tetris-new-block {
+ tetris_block=$tetris_block_next
+ __tetris-next-block
+ __tetris-draw-next-block
+ tetris_block_y=0
+ tetris_block_x=4
+ if ! __tetris-block-fits; then
+ __tetris-game-over
+ fi
+ __tetris-place-block "*"
+}
+
+function __tetris-left {
+ __tetris-place-block " "
+ (( tetris_block_x-- ))
+ __tetris-block-fits || (( tetris_block_x++ ))
+ __tetris-place-block "*"
+}
+
+function __tetris-right {
+ __tetris-place-block " "
+ (( tetris_block_x++ ))
+ __tetris-block-fits || (( tetris_block_x-- ))
+ __tetris-place-block "*"
+}
+
+function __tetris-rotate {
+ __tetris-place-block " "
+ local save_block=$tetris_block
+ tetris_block=$tetris_rotations[$tetris_block]
+ __tetris-block-fits || tetris_block=$save_block
+ __tetris-place-block "*"
+}
+
+function __tetris-drop {
+ __tetris-place-block " "
+ ((tetris_block_y++))
+ while __tetris-block-fits; do
+ ((tetris_block_y++))
+ ((tetris_score+=2))
+ done
+ ((tetris_block_y--))
+ __tetris-block-dropped
+}
+
+function __tetris-timeout {
+ __tetris-place-block " "
+ ((tetris_block_y++))
+ if __tetris-block-fits; then
+ __tetris-place-block "*"
+ return
+ fi
+ ((tetris_block_y--))
+ __tetris-block-dropped
+}
+
+function __tetris-block-dropped {
+ integer bonus=1
+ __tetris-place-block "O"
+ local fl=${tetris_blankline// /O} i=$((tetris_block_y*tetris_hsz))
+ repeat 4; do
+ if [[ $tetris_board[i+1,i+tetris_hsz] == $fl ]]; then
+ if (( fancygraphics )); then for char in {7..1}; do
+ tetris_board[i+1,i+tetris_hsz]=${tetris_blankline// /$char}
+ __tetris-render-screen
+ zcurses timeout score 50
+ zcurses input score
+ done; fi
+ tetris_board[i+1,i+tetris_hsz]=
+ tetris_board=$tetris_blankline$tetris_board
+ ((tetris_score+=100*(bonus++*(tetris_lines/10+10))))
+ ((tetris_lines+=1))
+ if ((tetris_lines % 10 == 0)); then
+ ((timestep = timestep * 0.80))
+ fi
+ fi
+ ((i += tetris_hsz))
+ done
+ __tetris-new-block
+}
+
+function __tetris-block-fits {
+ local y x i=$((1+tetris_block_y*tetris_hsz+tetris_block_x)) b=0x8000
+ for ((y=0; y!=4; y++)); do
+ for ((x=0; x!=4; x++)); do
+ if ((tetris_block&b)); then
+ ((x+tetris_block_x >= 0)) || return 1
+ ((x+tetris_block_x < tetris_hsz)) || return 1
+ ((y+tetris_block_y >= 0)) || return 1
+ ((y+tetris_block_y < tetris_vsz)) || return 1
+ [[ $tetris_board[i] == " " ]] || return 1
+ fi
+ ((b >>= 1))
+ ((i++))
+ done
+ ((i+=tetris_hsz-4))
+ done
+ return 0
+}
+
+function __tetris-draw-next-block {
+ local tetris_preview
+ local y x i=1 b=0x8000
+ for ((y=0; y!=4; y++)); do
+ tetris_preview=" "
+ for ((x=0; x!=4; x++)); do
+ ((tetris_block_next&b)) && tetris_preview[i]=\*
+ ((b >>= 1))
+ ((i++))
+ done
+ i=1
+ zcurses move preview $((y+1)) 1
+ zcurses string preview ${${${tetris_preview//O/$filled_block}//\*/$active_block}// / }
+ done
+}
+
+function __tetris-place-block {
+ local y x i=$((1+tetris_block_y*tetris_hsz+tetris_block_x)) b=0x8000
+ for ((y=0; y!=4; y++)); do
+ for ((x=0; x!=4; x++)); do
+ ((tetris_block&b)) && tetris_board[i]=$1
+ ((b >>= 1))
+ ((i++))
+ done
+ ((i+=tetris_hsz-4))
+ done
+}
+
+function __tetris-render-screen {
+ local i x piece
+ setopt localoptions histsubstpattern extendedglob
+ local -a match mbegin mend
+ local -A animation
+ animation=( 7 ▇▇ 6 ▆▆ 5 ▅▅ 4 ▄▄ 3 ▃▃ 2 ▂▂ 1 ▁▁ )
+ for (( i = 0; i < tetris_vsz; i++ )); do
+ zcurses move gamearea $(( i + 1 )) 1
+ zcurses string gamearea ${${${${${tetris_board[1+i*tetris_hsz,(i+1)*tetris_hsz]}//O/$filled_block}//\*/$active_block}// / }//(#b)([1-7])/$animation[$match[1]]}
+ done
+
+ zcurses clear score
+ zcurses move score 1 1
+ zcurses string score "Score: $tetris_score"$'\
+'" Lines: $tetris_lines"$'\
+'" Speed: ${timestep%.*} ms"
+
+ zcurses border gamearea
+ zcurses border score
+ zcurses border preview
+ zcurses refresh gamearea score preview $debug
+}
+
+function __tetris-game-over {
+ gameover=1
+}
+
+function __tetris-new-game {
+ gameover=0
+ timestep=1000
+ tetris_score=0
+ tetris_lines=0
+ __tetris-next-block
+ __tetris-new-block
+ __tetris-render-screen
+}
+
+function __tetris-game-over-screen {
+ __tetris-debug "Died with $tetris_score points!"
+ tetris_board=$tetris_blankboard
+ local text="You got $tetris_score points!"
+ local gameover_height=4 gameover_width=$(( $#text + 2 ))
+ zcurses addwin gameover $gameover_height $gameover_width \
+ $(( off_y + (game_height-gameover_height)/2 )) \
+ $(( off_x + (game_width+score_width-gameover_width)/2 ))
+ zcurses move gameover 1 1
+ zcurses string gameover $text
+ text='Play again? [yn]'
+ zcurses move gameover 2 $(( (gameover_width - $#text)/2 ))
+ zcurses string gameover $text
+ zcurses border gameover
+ keepplaying=
+ until [[ $keepplaying = [ynq] ]]; do
+ zcurses input gameover keepplaying
+ done
+ zcurses delwin gameover
+ zcurses refresh stdscr
+ zcurses timeout gamearea ${timestep%.*}
+ __tetris-new-game
+}
+
+function __tetris-debug {
+ if [[ -z $debug ]]; then
+ return
+ fi
+ zcurses scroll debug -1
+ zcurses move debug 0 0
+ zcurses string debug "$1"
+}
+
+function __tetris-remove-wins {
+ local delwin
+ local -a delwins
+ delwins=(gamearea score debug gameover help preview)
+ for delwin in ${delwins:*zcurses_windows}; do
+ zcurses delwin $delwin
+ done
+}
+
+function __tetris-help {
+ local i
+ local help_height=9 help_width=23
+ zcurses addwin help $help_height $help_width \
+ $(( off_y + (game_height - help_height) / 2 )) \
+ $(( off_x + (game_width + score_width - help_width) / 2 ))
+ zcurses move help 1 1
+ zcurses string help $'left: h, j, left\
+ right: right, n, l\
+ rotate: up, c, i\
+ soft drop: down, t, k\
+ hard drop: space\
+ quit: q\
+ press space to return'
+ zcurses border help
+ until [[ $i == [\ q] ]]; do
+ zcurses input help i
+ if [[ $i == q ]]; then
+ keepplaying=n
+ fi
+ done
+ zcurses delwin help
+ zcurses refresh stdscr
+}
+
+zmodload zsh/curses && {
+ zcurses init
+ __tetris-remove-wins
+ zcurses refresh
+ echoti civis
+ local debug=
+ if (( ${@[(I)--debug|-d]} )); then
+ debug=debug
+ fi
+ local off_x off_y
+ local game_height=22 game_width=25
+ local score_height=5 score_width=20
+ local preview_height=6 preview_width=10
+ local filled_block active_block
+ local fancygraphics
+ if zmodload zsh/langinfo && [[ $langinfo[CODESET] = UTF-8 ]]; then
+ filled_block=██
+ active_block=▒▒
+ fancygraphics=${@[(I)--silly]}
+ else
+ filled_block='[]'
+ active_block='()'
+ fancygraphics=0
+ fi
+ off_x=$(( (COLUMNS-game_width-score_width-1) / 2 ))
+ off_y=$(( (LINES-game_height) / 2 ))
+ zcurses clear stdscr redraw
+ zcurses refresh stdscr
+ zcurses addwin gamearea $game_height $game_width $off_y $off_x
+ zcurses scroll gamearea off
+ zcurses addwin score $score_height $score_width \
+ $off_y $(( off_x + game_width + 1 ))
+ zcurses scroll score off
+ zcurses addwin preview $preview_height $preview_width \
+ $(( off_y + score_height )) $(( off_x + game_width + 1 ))
+ zcurses scroll preview off
+ if [[ -n $debug ]]; then
+ zcurses addwin debug $(( game_height - score_height - preview_height - 1 )) \
+ $score_width \
+ $(( off_y + score_height + preview_height ))\
+ $(( off_x + game_width + 1 ))
+ fi
+ typeset -F SECONDS
+ local now prev timestep timeout key kkey keepplaying=y gameover=0
+ prev=$SECONDS
+ __tetris-new-game
+ zcurses timeout gamearea 0
+ while [[ $keepplaying == y ]]; do
+ if zcurses input gamearea key kkey; then
+ __tetris-debug "got input $key$kkey"
+ case $key$kkey in
+ LEFT|h|j) __tetris-left;;
+ RIGHT|n|l) __tetris-right;;
+ UP|c|i) __tetris-rotate;;
+ DOWN|t|k) __tetris-timeout; ((tetris_score++)); prev=$SECONDS;;
+ " ") __tetris-drop;;
+ q) break;;
+ F1|H) __tetris-help;;
+ esac
+ else
+ __tetris-debug "timed out"
+ __tetris-timeout
+ fi
+ now=$SECONDS
+ if (( prev + timestep/1000. < now )); then
+ (( prev += timestep/1000. ))
+ fi
+ timeout=${$(( 1000.*(prev + timestep/1000. - now) + 1 ))%.*}
+ if (( timeout < 0 )); then
+ __tetris-debug "BUG: timeout < 0"
+ timeout=${timestep%.*}
+ fi
+ zcurses timeout gamearea $timeout
+ __tetris-debug "timeout: $timeout"
+
+ __tetris-render-screen
+ if [[ $gameover == 1 ]]; then
+ __tetris-game-over-screen
+ fi
+ done
+} always {
+ __tetris-remove-wins
+ echoti cnorm
+ zcurses end
+}
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index ee50be6ca..c348da2a7 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -195,14 +195,6 @@ fi
VCS_INFO_adjust
VCS_INFO_git_getaction ${gitdir}
-
-VCS_INFO_get_get_rebase()
-{
- if [[ -f "$1" ]]; then
- echo "$(< "$1")"
- fi
-}
-
local patchdir=${gitdir}/patches/${gitbranch}
if [[ -d $patchdir ]] && [[ -f $patchdir/applied ]] \
&& [[ -f $patchdir/unapplied ]]
@@ -213,6 +205,7 @@ then
elif [[ -d "${gitdir}/rebase-merge" ]]; then
patchdir="${gitdir}/rebase-merge"
local p
+ [[ -f "${patchdir}/done" ]] &&
for p in ${(f)"$(< "${patchdir}/done")"}; do
# remove action
git_patches_applied+=("${${(s: :)p}[2,-1]}")
@@ -223,11 +216,16 @@ elif [[ -d "${gitdir}/rebase-apply" ]]; then
# Fake patch names for all but current patch
patchdir="${gitdir}/rebase-apply"
local cur=$(< "${patchdir}/next")
- local p
+ local p subject
for p in $(seq $(($cur - 1))); do
git_patches_applied+=("$(printf "%04d" $p) ?")
done
- git_patches_applied+=("$(< "${patchdir}/original-commit") ${${(f)$(< "${patchdir}/msg-clean")}[1]}")
+ subject="${$(< "${patchdir}/msg-clean")[(f)1]}"
+ if [[ -f "${patchdir}/original-commit" ]]; then
+ git_patches_applied+=("$(< ${patchdir}/original-commit) $subject")
+ else
+ git_patches_applied+=("? $subject")
+ fi
git_patches_unapplied=($(seq $cur $(< "${patchdir}/last")))
VCS_INFO_git_handle_patches
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index cedaf5676..1274ca337 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -6,6 +6,7 @@
setopt localoptions extendedglob NO_shwordsplit
local hgbase bmfile branchfile rebasefile dirstatefile mqseriesfile \
+ curbmfile curbm \
mqstatusfile mqguardsfile patchdir mergedir \
r_csetid r_lrev r_branch i_bmhash i_bmname \
revformat branchformat hgactionstring hgchanges \
@@ -24,6 +25,7 @@ r_lrev='' # local revision
patchdir="${hgbase}/.hg/patches"
mergedir="${hgbase}/.hg/merge/"
bmfile="${hgbase}/.hg/bookmarks"
+curbmfile="${hgbase}/.hg/bookmarks.current"
branchfile="${hgbase}/.hg/branch"
rebasefile="${hgbase}/.hg/rebasestate"
dirstatefile="${hgbase}/.hg/dirstate"
@@ -125,8 +127,23 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-bookmarks \
[[ $i_bmhash == $r_csetid* ]] && hgbmarks+=( $i_bmname )
done < ${bmfile}
+ if [[ -r "$curbmfile" ]] ; then
+ curbm=$(<"${curbmfile}")
+ hook_com[hg-active-bookmark]=$curbm
+ else
+ # leave curbm empty and [hg-active-bookmark] undefined.
+ fi
+
if VCS_INFO_hook 'gen-hg-bookmark-string' "${hgbmarks[@]}"; then
+ # If there is an active bookmark, annotate it and put it first.
+ if [[ -n $curbm ]] ; then
+ hgbmarks[(i)$curbm]=()
+ hgbmarks[1,0]="${curbm}*"
+ fi
hgbmstring=${(j:, :)hgbmarks}
+ # Deannotate the array, in case later code expects it to be valid.
+ # (The order is not restored.)
+ [[ -n $curbm ]] && hgbmarks[1]=${${hgbmarks[1]}[1,-2]}
else
hgbmstring=${hook_com[hg-bookmark-string]}
fi
diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index db15dda74..34ff1edbf 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -87,7 +87,7 @@ function VCS_INFO_quilt() {
local patches pc tmp qstring root
local -i ret
local -x context
- local -a applied unapplied all applied_string unapplied_string quiltcommand
+ local -a applied unapplied all applied_string unapplied_string quiltcommand quilt_env
local -Ax hook_com
context=":vcs_info:${vcs}.quilt-${mode}:${usercontext}:${rrn}"
@@ -105,17 +105,6 @@ function VCS_INFO_quilt() {
;;
esac
- zstyle -s "${context}" quilt-patch-dir patches || patches="${QUILT_PATCHES}"
- if [[ "${patches}" != /* ]]; then
- tmp=${patches:-patches}
- patches="$(VCS_INFO_quilt-dirfind "${tmp}")"
- ret=$?
- (( ret )) && return ${ret}
- patches=${patches}/${tmp}
- else
- [[ -d ${patches} ]] || return 1
- fi
-
pc="$(VCS_INFO_quilt-dirfind .pc .version)"
ret=$?
if (( ret == 0 )); then
@@ -129,12 +118,27 @@ function VCS_INFO_quilt() {
else
applied=()
fi
+ patches=$(<$pc/.quilt_patches)
fi
if zstyle -t "${context}" get-unapplied; then
# This zstyle call needs to be moved further up if `quilt' needs
# to be run in more places than this one.
zstyle -s "${context}" quiltcommand quiltcommand || quiltcommand='quilt'
- unapplied=( ${(f)"$(QUILT_PATCHES=$patches $quiltcommand --quiltrc /dev/null unapplied 2> /dev/null)"} )
+ quilt_env=(env)
+ if [ -z "$patches" ]; then
+ zstyle -s "${context}" quilt-patch-dir patches || patches="${QUILT_PATCHES}"
+ if [[ "${patches}" != /* ]]; then
+ tmp=${patches:-patches}
+ patches="$(VCS_INFO_quilt-dirfind "${tmp}")"
+ ret=$?
+ (( ret )) && return ${ret}
+ patches=${patches}/${tmp}
+ else
+ [[ -d ${patches} ]] || return 1
+ fi
+ quilt_env+=(QUILT_PATCHES="$patches")
+ fi
+ unapplied=( ${(f)"$(${quilt_env[@]} $quiltcommand --quiltrc /dev/null unapplied 2> /dev/null)"} )
unapplied=( ${unapplied:#} )
else
unapplied=()
diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info
index 5a421dfed..46938691d 100644
--- a/Functions/VCS_Info/vcs_info
+++ b/Functions/VCS_Info/vcs_info
@@ -94,6 +94,7 @@ vcs_info () {
for pat in ${dps} ; do
if [[ ${PWD} == ${~pat} ]] ; then
+ VCS_INFO_maxexports
[[ -n ${vcs_info_msg_0_} ]] && VCS_INFO_set --nvcs
return 0
fi
diff --git a/Functions/Zftp/zfcd_match b/Functions/Zftp/zfcd_match
index 95de4c583..9159f496c 100644
--- a/Functions/Zftp/zfcd_match
+++ b/Functions/Zftp/zfcd_match
@@ -12,7 +12,6 @@ fi
local ZFTP_VERBOSE=45
# should we redirect 2>/dev/null or let the user see it?
-local tmpf=${TMPPREFIX}zfcm$$
local -a match mbegin mend
if [[ $ZFTP_SYSTEM = UNIX* ]]; then
@@ -27,9 +26,10 @@ if [[ $ZFTP_SYSTEM = UNIX* ]]; then
# If we're using -F, we get away with using a directory
# to list, but not a glob. Don't ask me why.
reply=(${${(M)${(f)"$(zftp ls -lF $dir)"}:#d*}/(#b)*[[:space:]](*)\//$match[1]})
-# zftp ls -LF $dir >$tmpf
-# reply=($(awk '/\/$/ { print substr($1, 1, length($1)-1) }' $tmpf))
-# rm -f $tmpf
+# () {
+# zftp ls -LF $dir >|$1
+# reply=($(awk '/\/$/ { print substr($1, 1, length($1)-1) }' $1))
+# } =(<<<'')
[[ -n $dir && $dir != */ ]] && dir="$dir/"
if [[ -n $WIDGET ]]; then
_wanted directories expl 'remote directory' \
diff --git a/Functions/Zftp/zfcget b/Functions/Zftp/zfcget
index 476a730a6..569ee9de1 100644
--- a/Functions/Zftp/zfcget
+++ b/Functions/Zftp/zfcget
@@ -14,7 +14,7 @@ emulate -L zsh
[[ $curcontext = :zf* ]] || local curcontext=:zfcget
local loc rem stat=0 opt opt_G opt_t remlist locst remst
-local tmpfile=${TMPPREFIX}zfcget$$ rstat tsize
+local rstat tsize
while getopts :Gt opt; do
[[ $opt = '?' ]] && print "zfcget: bad option: -$OPTARG" && return 1
@@ -39,10 +39,11 @@ for remlist in $*; do
else
# Compare the sizes.
locst=($(zftp local $loc))
- zftp remote $rem >$tmpfile
- rstat=$?
- remst=($(<$tmpfile))
- rm -f $tmpfile
+ () {
+ zftp remote $rem >|$1
+ rstat=$?
+ remst=($(<$1))
+ } =(<<<'temporary file')
if [[ $rstat = 2 ]]; then
print "Server does not support SIZE command.\n" \
"Assuming you know what you're doing..." 2>&1
diff --git a/Functions/Zftp/zfcput b/Functions/Zftp/zfcput
index 85141b68d..eafecde78 100644
--- a/Functions/Zftp/zfcput
+++ b/Functions/Zftp/zfcput
@@ -14,7 +14,6 @@ emulate -L zsh
[[ $curcontext = :zf* ]] || local curcontext=:zfcput
local loc rem stat=0 locst remst offs tailtype
-local tmpfile=${TMPPREFIX}zfcget$$ rstat
# find how tail works. this is intensely annoying, since it's completely
# standard in C. od's no use, since we can only skip whole blocks.
@@ -40,10 +39,11 @@ for loc in $*; do
else
# Compare the sizes.
locst=($(zftp local $loc))
- zftp remote $rem >$tmpfile
- rstat=$?
- remst=($(<$tmpfile))
- rm -f $tmpfile
+ () {
+ zftp remote $rem >|$1
+ rstat=$?
+ remst=($(<$1))
+ } =(<<<'temporary file')
if [[ $rstat = 2 ]]; then
print "Server does not support remote status commands.\n" \
"You will have to find out the size by hand and use zftp append." 2>&1
diff --git a/Functions/Zftp/zffcache b/Functions/Zftp/zffcache
index 48afdcba0..b609c2104 100644
--- a/Functions/Zftp/zffcache
+++ b/Functions/Zftp/zffcache
@@ -19,8 +19,5 @@ fi
if [[ $1 = -d ]]; then
unset $fcache_name
elif (( ${(P)#fcache_name} == 0 )); then
- local tmpf=${TMPPREFIX}zffcache$$
- zftp ls >$tmpf
- eval "$fcache_name=(\${(f)\"\$(<\$tmpf)\"})"
- rm -f $tmpf
+ eval "$fcache_name=(\${(f)\"\$(zftp ls)\"})"
fi
diff --git a/Functions/Zftp/zfget_match b/Functions/Zftp/zfget_match
index 1d90bea60..3a33c9886 100644
--- a/Functions/Zftp/zfget_match
+++ b/Functions/Zftp/zfget_match
@@ -1,28 +1,29 @@
# function zfget_match {
emulate -L zsh
+zmodload -F zsh/files b:zf_ln || return 1
# the zfcd hack: this may not be necessary here
if [[ $1 == $HOME || $1 == $HOME/* ]]; then
1="~${1#$HOME}"
fi
-local tmpf=${TMPPREFIX}zfgm$$
-
if [[ $ZFTP_SYSTEM == UNIX* && $1 == */* ]]; then
+ setopt localoptions clobber
+ local tmpf=${TMPPREFIX}zfgm$$
+ zf_ln -fn =(<<<'') $tmpf || return 1
+
if [[ -n $WIDGET ]]; then
local dir=${1:h}
[[ $dir = */ ]] || dir="$dir/"
zftp ls -LF $dir >$tmpf
local reply
reply=(${${${(f)"$(<$tmpf)"}##$dir}%\*})
- rm -f $tmpf
_wanted files expl 'remote file' compadd -P $dir - $reply
else
# On the first argument to ls, we usually get away with a glob.
zftp ls "$1*$2" >$tmpf
reply=($(<$tmpf))
- rm -f $tmpf
fi
else
local fcache_name
diff --git a/Functions/Zftp/zfrglob b/Functions/Zftp/zfrglob
index 1fb8d761a..677b85f4b 100644
--- a/Functions/Zftp/zfrglob
+++ b/Functions/Zftp/zfrglob
@@ -33,12 +33,12 @@ if [[ $pat != *[][*?]* &&
( -n $zfrglob || $pat != *[(|)#^]* ) ]]; then
return 0
fi
-local tmpf=${TMPPREFIX}zfrglob$$
if [[ $zfrglob != '' ]]; then
- zftp ls "$pat" >$tmpf 2>/dev/null
- eval "$1=(\$(<\$tmpf))"
- rm -f $tmpf
+ () {
+ zftp ls "$pat" >|$1 2>/dev/null
+ eval "$1=(\$(<\$1))"
+ } =(<<<'temporary file')
else
if [[ $ZFTP_SYSTEM = UNIX* && $pat = */* ]]; then
# not the current directory and we know how to handle paths
@@ -49,10 +49,11 @@ else
dir=/
fi
nondir=${pat##*/}
- zftp ls "$dir" 2>/dev/null >$tmpf
- files=($(<$tmpf))
+ () {
+ zftp ls "$dir" 2>/dev/null >|$1
+ files=($(<$1))
+ } =(<<<'temporary file')
files=(${files:t})
- rm -f $tmpf
else
# we just have to do an ls and hope that's right
local fcache_name
diff --git a/Functions/Zftp/zftransfer b/Functions/Zftp/zftransfer
index c70bf7248..c97ae4645 100644
--- a/Functions/Zftp/zftransfer
+++ b/Functions/Zftp/zftransfer
@@ -43,10 +43,11 @@ zfautocheck || return 1
local style
zstyle -s ':zftp:zftransfer' progress style
if [[ -n $style && $style != none ]]; then
- local ZFTP_TSIZE array tmpfile=${TMPPREFIX}zft$$
- zftp remote $file1 >$tmpfile 2>/dev/null
- array=($(<$tmpfile))
- rm -f $tmpfile
+ local ZFTP_TSIZE array
+ () {
+ zftp remote $file1 >|$1 2>/dev/null
+ array=($(<$1))
+ } =(<<<'temporary file')
[[ $#array -eq 2 ]] && ZFTP_TSIZE=$array[1]
fi
diff --git a/Functions/Zftp/zftype b/Functions/Zftp/zftype
index 0cdf7e2aa..81f95dece 100644
--- a/Functions/Zftp/zftype
+++ b/Functions/Zftp/zftype
@@ -1,13 +1,11 @@
# function zftype {
-local type zftmp=${TMPPREFIX}zftype$$
+local type
[[ $curcontext = :zf* ]] || local curcontext=:zftype
zfautocheck -d
if (( $# == 0 )); then
- zftp type >$zftmp
- type=$(<$zftmp)
- rm -f $zftmp
+ type=$(zftp type)
if [[ $type = I ]]; then
print "Current type is image (binary)"
return 0
diff --git a/Functions/Zftp/zfuget b/Functions/Zftp/zfuget
index c1033c930..2850975e7 100644
--- a/Functions/Zftp/zfuget
+++ b/Functions/Zftp/zfuget
@@ -26,7 +26,7 @@
emulate -L zsh
[[ $curcontext = :zf* ]] || local curcontext=:zfuget
-local loc rem locstats remstats doit tmpfile=${TMPPREFIX}zfuget$$
+local loc rem locstats remstats doit
local rstat remlist opt opt_v opt_s opt_G opt_t
integer stat do_close
@@ -66,12 +66,13 @@ for remlist in $*; do
doit=y
remstats=()
if [[ -f $loc ]]; then
- zftp local $loc >$tmpfile
- locstats=($(<$tmpfile))
- zftp remote $rem >$tmpfile
- rstat=$?
- remstats=($(<$tmpfile))
- rm -f $tmpfile
+ () {
+ zftp local $loc >|$1
+ locstats=($(<$1))
+ zftp remote $rem >|$1
+ rstat=$?
+ remstats=($(<$1))
+ } =(<<<'temporary file')
if [[ $rstat = 2 ]]; then
print "Server does not implement full command set required." 1>&2
return 1
diff --git a/Functions/Zftp/zfuput b/Functions/Zftp/zfuput
index 4e0e42dcd..f4e6a0fd6 100644
--- a/Functions/Zftp/zfuput
+++ b/Functions/Zftp/zfuput
@@ -12,7 +12,7 @@
emulate -L zsh
[[ $curcontext = :zf* ]] || local curcontext=:zfuput
-local loc rem locstats remstats doit tmpfile=${TMPPREFIX}zfuput$$
+local loc rem locstats remstats doit
local rstat opt opt_v opt_s
integer stat do_close
@@ -52,12 +52,13 @@ for rem in $*; do
stat=1
continue
fi
- zftp local $loc >$tmpfile
- locstats=($(<$tmpfile))
- zftp remote $rem >$tmpfile
- rstat=$?
- remstats=($(<$tmpfile))
- rm -f $tmpfile
+ () {
+ zftp local $loc >|$1
+ locstats=($(<$1))
+ zftp remote $rem >|$1
+ rstat=$?
+ remstats=($(<$1))
+ } =(<<<'temporary file')
if [[ $rstat = 2 ]]; then
print "Server does not implement full command set required." 1>&2
return 1
diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line
index 250cac65f..100af9601 100644
--- a/Functions/Zle/edit-command-line
+++ b/Functions/Zle/edit-command-line
@@ -6,12 +6,10 @@
# will give ksh-like behaviour for that key,
# except that it will handle multi-line buffers properly.
-local tmpfile=${TMPPREFIX:-/tmp/zsh}ecl$$
+() {
+ exec </dev/tty
+ ${=${VISUAL:-${EDITOR:-vi}}} $1
+ print -Rz - "$(<$1)"
+} =(<<<"$PREBUFFER$BUFFER")
-print -R - "$PREBUFFER$BUFFER" >$tmpfile
-exec </dev/tty
-${=${VISUAL:-${EDITOR:-vi}}} $tmpfile
-print -Rz - "$(<$tmpfile)"
-
-command rm -f $tmpfile
zle send-break # Force reload from the buffer stack