Skip to content

Instantly share code, notes, and snippets.

View nerd190's full-sized avatar
🤓
coding to music 🎵

Scott nerd190

🤓
coding to music 🎵
  • London
View GitHub Profile
#!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'
#!/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
#!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
}
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@zbyhoo
zbyhoo / gist:805695
Created February 1, 2011 10:45
vim function to execute shell command and show output in vim window
function! s:ExecuteInShell(command)
let command = join(map(split(a:command), 'expand(v:val)'))
let winnr = bufwinnr('^' . command . '$')
silent! execute winnr < 0 ? 'botright new ' . fnameescape(command) : winnr . 'wincmd w'
setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap number
echo 'Execute ' . command . '...'
silent! execute 'silent %!'. command
silent! execute 'resize ' . line('$')
silent! redraw
silent! execute 'au BufUnload <buffer> execute bufwinnr(' . bufnr('#') . ') . ''wincmd w'''
# 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"