Skip to content

Instantly share code, notes, and snippets.

@dohq
dohq / get_info.sh
Created January 27, 2015 04:37
CheckReturnCode
### リターンコードチェック関数
function common_func_CheckRC(){
if [ $# -eq 1 ]; then
if [ $1 -ne 0 ]; then
echo "情報取得に失敗しました。出力ファイルを確認して下さい。"
echo "リターンコード : "$1""
exit 1
fi
else
echo "引数が足りません。"
@dohq
dohq / cvimrc
Last active April 23, 2021 02:00
cvimrc
" change default search engine
" unmap t
" map t :tabnew duckduckgo<space>
"Settings
let barposition = "top"
let blacklists = ["https://*.vultr.com/*", "https://docs.google.com/*", "https://*.qmk.fm/*", "https://thetypingcat.com/*", "https://remotedesktop.google.com/*"]
let fullpagescrollpercent = 100
let hintcharacters = "asdfghjkl"
let locale = "jp"
let mapleader = ","
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"io/ioutil"
"net/http"
"net/url"
@dohq
dohq / peco-history.zsh
Last active September 21, 2018 15:27
peco-history.zsh
#bindkey '^R' history-incremental-pattern-search-backward
setopt hist_ignore_all_dups
function peco_select_history() {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER
@dohq
dohq / peco-branch.zsh
Last active September 21, 2018 15:26
peco-branch
#bindkey '^B' select branch for Peco
function peco-branch () {
local branch=$(git branch -a | peco | tr -d ' ' | tr -d '*')
if [ -n "$branch" ]; then
if [ -n "$LBUFFER" ]; then
local new_left="${LBUFFER%\ } $branch"
else
local new_left="$branch"
fi
BUFFER=${new_left}${RBUFFER}
@dohq
dohq / peco-ghq.zsh
Last active September 21, 2018 15:27
peco-ghq.zsh
#bindkey '^g' list ghq src
function peco-ghq () {
local selected_dir=$(ghq list -p | peco --query "$LBUFFER")
if [ -n "$selected_dir" ]; then
BUFFER="cd ${selected_dir}"
zle accept-line
fi
zle clear-screen
}
zle -N peco-ghq
@dohq
dohq / fzf-ghq.zsh
Last active January 28, 2020 09:09
fzf-ghq
function fzf-ghq() {
local selected_dir=$(ghq list |fzf --prompt="Git Repos > " --preview "bat --color=always --style=header,grid --line-range :80 $(ghq root)/{}/README.*")
if [ -n "$selected_dir" ]; then
BUFFER="cd $(ghq root)/${selected_dir}"
zle accept-line
fi
zle reset-prompt
}
@dohq
dohq / fzf-branch.zsh
Last active July 27, 2019 10:12
fzf-branch
function fzf-branch() {
local selected_branch=$(git for-each-ref --format='%(refname)' --sort=-committerdate refs/heads | perl -pne 's{^refs/heads/}{}' | fzf --query "$LBUFFER" --prompt="Git Branch > ")
if [ -n "$selected_branch" ]; then
BUFFER="git checkout ${selected_branch}"
zle accept-line
fi
zle reset-prompt
}
@dohq
dohq / fzf-ssh.zsh
Last active March 21, 2024 14:44
fzf-ssh
function fzf-ssh () {
local selected_host=$(grep "Host " ~/.ssh/ssh_config | grep -v '*' | cut -b 6- | fzf --query "$LBUFFER" --prompt="SSH Remote > ")
if [ -n "$selected_host" ]; then
BUFFER="ssh ${selected_host}"
zle accept-line
fi
zle reset-prompt
}
@dohq
dohq / fzf-history.zsh
Last active July 26, 2019 02:40
fzf-history
setopt hist_ignore_all_dups
function fzf-history() {
BUFFER=$(history -n -r 1 | fzf --no-sort +m --query "$LBUFFER" --prompt="History > ")
CURSOR=$#BUFFER
zle clear-screen
}
zle -N fzf-history
bindkey '^r' fzf-history