Skip to content

Instantly share code, notes, and snippets.

View hchbaw's full-sized avatar

Takeshi Banse hchbaw

View GitHub Profile
#autoload +X
__git_files () {
local expl files ls_opts opts gitdir gitcdup
zparseopts -D -E -a opts -- -cached -deleted -modified -others -ignored -unmerged -killed
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
__git_command_successful || return
#autoload +X
__git_files () {
local expl
_wanted files expl 'file' _files
}
#autoload +X
__git_files () {
local expl files ls_opts opts gitdir gitcdup
zparseopts -D -E -a opts -- -cached -deleted -modified -others -ignored -unmerged -killed
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
__git_command_successful || return
#!zsh
# 直前のコマンドを再度実行して、その出力を補完候補するようなスクリプトです
_complete_previous_output () {
local command xs
command=${(Q)$(fc -l -n -1)}
xs=(${(f)"$(${=command})"})
_message "($command)"
#!zsh
# 直前のコマンドラインの要素を補完候補にするようなスクリプトです。
_complete_previous_commandline () {
local cl xs
cl="$(fc -l -n -1)"
xs=${(@z)cl}
compadd \
#!zsh
# コマンドライン上の今のカーソルの左の要素の展開具合を補完候補にするようなス
# クリプトです。
_expand_word_fu () {
compstate[insert]=
local origprefix=$PREFIX
case $origprefix[1] in
#!zsh
# エディタのファイルの履歴を補完候補にするようなスクリプトです
_rf () {
local ref=$1
shift
local -a xs
xs=("$@")
local -a ret
ret=()
#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
# _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'