Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jidaikobo-shibata
Last active November 28, 2015 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jidaikobo-shibata/e3cafdf53810290c34c9 to your computer and use it in GitHub Desktop.
Save jidaikobo-shibata/e3cafdf53810290c34c9 to your computer and use it in GitHub Desktop.
shellscripts of MacOS X+bash4+peco
#!/bin/bash
# peco-open-emacs
function peco-open-emacs
{
local files="$( find . -type f | peco )"
files_str=''
for file in $files
do
files_str=$files_str' '$file
done
open -a /Applications/Emacs.app $files_str
}
alias pce="peco-open-emacs"
# peco-open-JeditX
function peco-open-JeditX
{
local files="$( find . -type f | peco )"
files_str=''
for file in $files
do
files_str=$files_str' '$file
done
open -a /Applications/Jedit\ X/Jedit\ X.app $files_str
}
alias pcj="peco-open-JeditX"
# peco-open-mvim
function peco-open-mvim
{
local files="$( find . -type f | peco )"
files_str=''
for file in $files
do
files_str=$files_str' '$file
done
mvim -p $files_str
}
alias pcm="peco-open-mvim"
# peco-history
# thx http://www.fisproject.jp/2015/01/peco/
function peco-history
{
declare l=$(HISTTIMEFORMAT= history | sort -k1,1nr | perl -ne 'BEGIN { my @lines = (); } s/^\s*\d+\s*//; $in=$_; if (!(grep {$in eq $_} @lines)) { push(@lines, $in); print $in; }' | peco --query "$READLINE_LINE")
READLINE_LINE="$l"
READLINE_POINT=${#l}
# for OSX
if [ `uname` = "Darwin" ]; then
${READLINE_LINE}
fi
}
#bind -x '"\C-r": peco-select-history'
alias pch="peco-history"
# peco-cd
function peco-cd
{
local found="$( find . -type d | peco )"
cd "$found"
}
alias pcc="peco-cd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment