Skip to content

Instantly share code, notes, and snippets.

View hchbaw's full-sized avatar

Takeshi Banse hchbaw

View GitHub Profile
#compdef clbuild
# TODO: clbuild-bash-completion.sh stuff (run/update/install/uninstall)
# Especially `update' found in this script is totally broken:)
_clbuild () {
local clbuild_dir=${clbuild_dir:=$(pwd)}
(( $+functions[__clbuild_commands] )) ||
__clbuild_commands () {
#!zsh
# _git vcs_info
# __git_branch_switches
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
#zstyle ':vcs_info:*' formats '%B%F{black}(%f%b%F{black})%f%%b' # `%f` eats "1"
zstyle ':vcs_info:*' formats '%B%F{black}(%F{white}%b%F{black})%f%%b'
zstyle ':vcs_info:*' actionformats '%B%F{black}(%F{white}%b%F{black}|%F{white}%a%F{black})%f%%b'
(defmacro aif (test-form then-form &optional else-form)
(declare (indent 1))
`(let ((it ,test-form))
(if it ,then-form ,else-form)))
(defmacro aand (&rest args)
(declare (indent 0))
(cond ((null args) t)
((null (cdr args)) (car args))
(t `(aif ,(car args)
;; http://repo.or.cz/w/emacs.git/blob/HEAD:/src/fileio.c#l5557
;; (install-my-restore-message-function alcs-make-candidates)
(defmacro w/uniq (names &rest body)
(declare (indent 1))
`(let ,(mapcar (lambda (s) `(,s (gensym ,(symbol-name s))))
(if (consp names) names (list names)))
,@body))
(defmacro with-my-restore-message (&rest body)
#autoload
local -a flags
flags=(
'):end of flags'
'#:as numeric'
'%:expand %s in result as in prompts'
'@:array expand even in double quotes'
'A:create an array parameter with ${...=...}, (AA) associative array'
#!zsh
# エディタのファイルの履歴を補完候補にするようなスクリプトです
_rf () {
local ref=$1
shift
local -a xs
xs=("$@")
local -a ret
ret=()
#!zsh
# コマンドライン上の今のカーソルの左の要素の展開具合を補完候補にするようなス
# クリプトです。
_expand_word_fu () {
compstate[insert]=
local origprefix=$PREFIX
case $origprefix[1] in
#!zsh
# 直前のコマンドラインの要素を補完候補にするようなスクリプトです。
_complete_previous_commandline () {
local cl xs
cl="$(fc -l -n -1)"
xs=${(@z)cl}
compadd \
#!zsh
# 直前のコマンドを再度実行して、その出力を補完候補するようなスクリプトです
_complete_previous_output () {
local command xs
command=${(Q)$(fc -l -n -1)}
xs=(${(f)"$(${=command})"})
_message "($command)"