Skip to content

Instantly share code, notes, and snippets.

View hchbaw's full-sized avatar

Takeshi Banse hchbaw

View GitHub Profile
#!/usr/local/bin/gosh
;;; stuff such that .zhistory → “"cdr" function for recent directories etc.”
;;; - http://thread.gmane.org/gmane.comp.shells.zsh.devel/20592
#|
% {
local -a match mbegin mend
print -l ${${(@f)"$(\
gosh /tmp/cdr.scm -f $HISTFILE -t $((12 * 60 * 60)) -l 99999 \
)"}/(#b)(*)/\$"'"${match}"'"}
} > ~/..chpwd-recent-dirs
# zaw.zsh source for the elements of the directory stack.
# https://github.com/nakamuray/zaw
# Thank you very much, nakamuray!
zmodload zsh/parameter
function zaw-src-dirstack() {
: ${(A)candidates::=$dirstack}
actions=("zaw-callback-execute" "zaw-callback-replace-buffer" "zaw-callback-append-to-buffer")
act_descriptions=("execute" "replace edit buffer" "append to edit buffer")
# zaw.zsh source for 'git show-branch'.
# Thank you very much, nakamuray!
# https://github.com/nakamuray/zaw
zaw-src-git-showbranch () {
git rev-parse -q --is-inside-work-tree >/dev/null || return 1
#local b="${orig_lbuffer}${orig_rbuffer}"
local b="$BUFFER"
local z="$(git rev-parse --git-dir)""/zaw-src-git-showbranch"
#compdef - my-zargs t
setopt localoptions extendedglob
() {
local -a tmp0 tmp1 tmp
# copied from _zargs
echo "\
-eof::=eof e::=eof \
-exit x \
#!zsh
# textobj-between code.
# Thank you very much, thinca and tarao!
#
# http://d.hatena.ne.jp/thinca/20100614/1276448745
# http://d.hatena.ne.jp/tarao/20100715/1279185753
def-oppc-textobj-between () {
def-oppc-inbetween-2 "$1" "opp+i$1" "opp+a$1" oppc-tb-main
}
@hchbaw
hchbaw / el.el
Last active August 12, 2017 14:21
;; https://twitter.com/supermomonga/status/889235209782046720
;;
;; https://twitter.com/hchbaw/status/895745817897689088
;; https://twitter.com/hchbaw/status/895984112988692481
(defmacro my-eflet (specs &rest body)
(declare (indent 1))
(let ((garg (cl-gensym "args--")))
`(cl-flet (,@(loop for (n b) in specs
collect
`(,@(pcase b
;; https://teratail.com/questions/83177
(use srfi-14 :only (char-set->list))
(define (pr xxs)
(define (stringify xxs listref)
(string-join (concatenate (map listref xxs)) " "))
(begin
($ print $ stringify xxs car)
% git for-each-ref 'refs/tags/v4.10*' --count=5 --sort='-*authordate' \
--format='%(align:8,left)%(refname:short)%(end)%(*authordate:short) %(*authordate:relative)'
v4.10.4 2017-03-18 3 hours ago
v4.10.3 2017-03-15 4 days ago
v4.10.2 2017-03-12 6 days ago
v4.10.1 2017-02-26 3 weeks ago
v4.10 2017-02-19 4 weeks ago
(defmacro with-my-anything-follow-mode (push-mark &rest body)
(declare (indent 1))
(let ((gf (gensym)))
`(letf (((symbol-function 'push-mark)
(symbol-function 'ignore)))
(letf* ((,gf
(symbol-function 'anything-initialize-overlays))
((symbol-function 'anything-initialize-overlays)
(lambda (buffer)
(funcall ,gf buffer)
@hchbaw
hchbaw / Makefile
Last active November 24, 2016 04:15
all::
test:
prove --exec zsh test.zsh -v
clean:
rm -rf ./.test-data
rm -f tmp*
.PHONY: test clean