Skip to content

Instantly share code, notes, and snippets.

@takahiro47
Created November 4, 2017 16:50
Show Gist options
  • Save takahiro47/24a4f61413909af0f73caa6182ff4db0 to your computer and use it in GitHub Desktop.
Save takahiro47/24a4f61413909af0f73caa6182ff4db0 to your computer and use it in GitHub Desktop.
## zplug
##----------------------------------##
export ZPLUG_HOME=/usr/local/opt/zplug
source $ZPLUG_HOME/init.zsh
zplug 'zplug/zplug', hook-build:'zplug --self-manage'
# enhancd config
export ENHANCD_COMMAND=ed
export ENHANCD_FILTER=ENHANCD_FILTER=fzy:fzf:peco
# Vanilla shell
zplug 'yous/vanilli.sh'
# A Zsh plugin to help remembering those shell aliases and Git aliases you once defined.
zplug 'djui/alias-tips', use:alias-tips.plugin.zsh, defer:3
# Additional completion definitions for Zsh
zplug 'zsh-users/zsh-completions'
# Syntax highlighting bundle. zsh-syntax-highlighting must be loaded after
# excuting compinit command and sourcing other plugins.
zplug "zsh-users/zsh-syntax-highlighting", defer:2
# Fish-like fast/unobtrusive autosuggestions for zsh.
# It suggests commands as you type, based on command history.
zplug 'zsh-users/zsh-autosuggestions'
# ZSH port of Fish shell's history search feature
zplug "zsh-users/zsh-history-substring-search"
# Tracks your most used directories, based on 'frecency'.
zplug "rupa/z", use:"*.sh"
# A next-generation cd command with an interactive filter
zplug "b4b4r07/enhancd", use:init.sh
# emoji
# brew install jq fzf peco
zplug "stedolan/jq", from:gh-r, as:command
zplug "b4b4r07/emoji-cli", if:"which jq"
# This plugin adds many useful aliases and functions.
# zplug "plugins/aws", from:oh-my-zsh
# zplug "plugins/bower", from:oh-my-zsh
zplug "plugins/brew", from:oh-my-zsh, defer:3
zplug "plugins/brew-cask", from:oh-my-zsh, defer:3
zplug "plugins/bundler", from:oh-my-zsh
zplug "plugins/coffee", from:oh-my-zsh
zplug "plugins/colorize", from:oh-my-zsh
zplug "plugins/common-alias", from:oh-my-zsh, defer:3
zplug "plugins/encode64", from:oh-my-zsh
zplug "plugins/gem", from:oh-my-zsh
zplug "plugins/git", from:oh-my-zsh, defer:3
zplug "plugins/github", from:oh-my-zsh
# zplug "plugins/node", from:oh-my-zsh
# zplug "plugins/npm", from:oh-my-zsh
zplug "plugins/osx", from:oh-my-zsh, if:"[[ $OSTYPE == *darwin* ]]"
# zplug "plugins/pip", from:oh-my-zsh
# zplug "plugins/python", from:oh-my-zsh
# zplug "plugins/rails", from:oh-my-zsh
# zplug "plugins/redis-cli", from:oh-my-zsh
# zplug "plugins/ruby", from:oh-my-zsh
zplug "plugins/sublime", from:oh-my-zsh
zplug "plugins/sudo", from:oh-my-zsh
zplug "plugins/vagrant", from:oh-my-zsh
zplug "plugins/web-search", from:oh-my-zsh
zplug "plugins/zsh_reload", from:oh-my-zsh
# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
# Load theme file
# export TERM="xterm-256color"
# zplug 'yous/lime', as:theme
# zplug 'themes/wedisagree', from:oh-my-zsh, as:theme
# zplug 'themes/powerlevel9k', from:oh-my-zsh, as:theme
zplug 'themes/wezm+', from:oh-my-zsh, as:theme
# Powerline Theme
zplug "bhilburn/powerlevel9k", at:next, hook-build:"cp $ZPLUG_HOME/repos/bhilburn/powerlevel9k/powerlevel9k.zsh-theme $ZPLUG_HOME/repos/sorin-ionescu/prezto/modules/prompt/functions/prompt_powerlevel9k_setup && cp -rp $ZPLUG_HOME/repos/bhilburn/powerlevel9k/functions $ZPLUG_HOME/repos/sorin-ionescu/prezto/modules/prompt/functions"
# Then, source plugins and add commands to $PATH
# zplug load --verbose
zplug load
## zplug の設定
##----------------------------------##
# Lime theme settings
export LIME_DIR_DISPLAY_COMPONENTS=2
# Better history searching with arrow keys
if zplug check "zsh-users/zsh-history-substring-search"; then
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
fi
# Add color to ls command
export CLICOLOR=1
# NeoVim config
export XDG_CONFIG_HOME=$HOME/.xdgconfig
# Load rbenv
if [ -e "$HOME/.rbenv" ]; then
eval "$(rbenv init - zsh)"
fi
# Set GOPATH for Go
if command -v go &> /dev/null; then
[ -d "$HOME/go" ] || mkdir "$HOME/go"
export GOPATH="$HOME/go"
export GOROOT=/usr/local/opt/go/libexec
export PATH="$PATH:$GOPATH/bin:$GOROOT/bin"
fi
# Set PATH for GAE
export PATH=$HOME/go/appengine:$PATH
# 補完 の設定
##----------------------------------##
# 初期化(zsh-completions利用を想定)
fpath=(/usr/local/share/zsh-completions $fpath)
autoload -Uz compinit
compinit -u
# 補完方法毎にグループ化
## 補完方法の表示方法
## %B...%b: 「...」を太字に
## %d: 補完方法のラベル
zstyle ':completion:*' format '%B%d%b'
zstyle ':completion:*' group-name ''
# 補完侯補をメニューから選択
## select=2: 補完候補を一覧から選択
## ただし、補完候補が2つ以上なければすぐに補完
zstyle ':completion:*:default' menu select=2
# 補完候補に色を付ける
## "": 空文字列はデフォルト値を使うという意味を表す
zstyle ':completion:*:default' list-colors ""
# 補完候補がなければより曖昧に候補を探す
## m:{a-z}={A-Z}: 小文字を大文字に変えたものでも補完
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# 補完方法の設定。指定した順番に実行
## _oldlist 前回の補完結果を再利用
## _complete: 補完す
## _match: globを展開しないで候補の一覧から補完
## _ignored: 補完候補にださないと指定したものも補完候補
## _approximate: 似ている補完候補も補完候補
## _prefix: カーソル以降を無視してカーソル位置までで補完
zstyle ':completion:*' completer _oldlist _complete _match _ignored _approximate _prefix
# 補完候補をキャッシュ
zstyle ':completion:*' use-cache yes
# 詳細な情報を使用
zstyle ':completion:*' verbose yes
# sudo時にはsudo用のパスも使用
zstyle ':completion:sudo:*' environ PATH="$SUDO_PATH:$PATH"
# カーソル位置で補完
setopt complete_in_word
# globを展開しないで候補の一覧から補完
setopt glob_complete
# 補完時にヒストリを自動的に展開
setopt hist_expand
# 補完候補がないときなどにビープ音を鳴らさない
setopt no_beep
# 辞書順ではなく数字順に並べる
setopt numeric_glob_sort
# --prefix=~/localというように「=」の後でも「~」や「=コマンド」などのファイル名展開を実行
setopt magic_equal_subst
# 拡張globを有効に (glob中で「(#...)」という書式で指定)
setopt extended_glob
# globでパスを生成したときに、パスがディレクトリだったら最後に「/」を付加
setopt mark_dirs
## Path の設定
##----------------------------------##
# Oracle database
export DYLD_LIBRARY_PATH="/opt/oracle/instantclient_11_2:$DYLD_LIBRARY_PATH"
export PATH="/opt/oracle/instantclient_11_2:$PATH"
# GCC
export CC="/usr/bin/gcc"
# man
export MANPATH="/usr/local/man:$MANPATH"
# Homebrew
export PATH="/usr/local/bin:$PATH" # "$(brew --prefix)/bin:$PATH"
export PATH="/usr/local/sbin:$PATH" # "$(brew --prefix)/sbin:$PATH"
# MySQL
export PATH="/usr/local/mysql/bin:$PATH"
# PHP / PEAR => http://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew
export PATH="$(brew --prefix homebrew/php/php55)/bin:$PATH"
export PATH="$HOME/pear/bin:$PATH"
PHP_AUTOCONF="'$(which autoconf)'"
# Ruby
# brew install rbenv-default-gems
# http://yosiwo.lowtech.ne.jp/?p=1547 => 2.x系のエラー対処
export RBENV_ROOT="/usr/local/var/rbenv"
export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
# node.js
export PATH="$HOME/node_modules/.bin:$PATH"
export PATH="/usr/local/share/npm/bin:$PATH"
# Python
export FONT_PATH="$HOME/Library/Fonts/Ricty-Regular.ttf"
export PYENV_ROOT="/usr/local/var/pyenv"
export PATH="$PATH:$PYENV_ROOT/bin"
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
# Go
export PATH="/usr/local/opt/go/libexec/bin:$PATH"
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
### Added by the Bluemix CLI
source /usr/local/Bluemix/bx/zsh_autocomplete
# elasticsearch
export ELASTIC_SEARCH="/usr/local/elasticsearch"
export PATH="$ELASTIC_SEARCH/bin:$PATH"
# Tex
# export http_proxy=http://proxy.hoge:8080
# export HTTP_PROXY=$http_proxy
# export https_proxy=$http_proxy
# export HTTPS_PROXY=$http_proxy
# export ftp_proxy=$http_proxy
# export FTP_PROXY=$http_proxy
# export no_proxy=.local,localhost,127.0.0.1
# export use_proxy=yes
export PATH="/usr/texbin:$PATH"
# original
export PATH="$HOME/.bin:$PATH"
# User Command
export PATH="/data/bin:$PATH"
# You may need to manually set your language environment
export LANG=ja_JP.UTF-8
export LC_ALL=ja_JP.UTF-8
export FONTCONFIG_PATH=/Users/takahiro/.config/fontconfig
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=iso-2022-jp,euc-jp,utf-8,ucs2le,ucs-2
LESSCHARSET=utf-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"
alias crontab="VIM_CRONTAB=true crontab"
## Powerline & tmux
##----------------------------------##
POWERLINE_SHOW_GIT_ON_RIGHT="true"
POWERLINE_DETECT_SSH="true"
POWERLINE_GIT_CLEAN=""
POWERLINE_GIT_DIRTY=""
POWERLINE_GIT_ADDED="%F{green}✚%F{black}"
POWERLINE_GIT_MODIFIED="%F{blue}✹%F{black}"
POWERLINE_GIT_DELETED="%F{red}✖%F{black}"
POWERLINE_GIT_UNTRACKED="%F{yellow}✭%F{black}"
POWERLINE_GIT_RENAMED=""
POWERLINE_GIT_UNMERGED=""
ZSH_TMUX_AUTOSTART=false
## エイリアス(コマンド)
##----------------------------------##
# System
alias os.sleep="osascript -e 'tell application \"Finder\" to sleep'"
alias os.shutdown="osascript -e 'tell application \"Finder\" to shut down'"
alias os.reboot="osascript -e 'tell application \"Finder\" to restart'"
alias shutdown="sudo shutdown -h now"
alias reboot="sudo shutdown -r now"
# Applications
# alias subl="sublime" # Sublime Text 3
# Hosts
alias hosts.edit="subl /etc/hosts"
alias hosts.reload="sudo dscacheutil -flushcache"
## nginx / php-fpm
alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist"
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist"
alias php-fpm.restart='php-fpm.stop && php-fpm.start'
alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.restart='mysql.stop && mysql.start'
alias nginx.logs.error='tail -250f /usr/local/etc/nginx/logs/error.log'
alias nginx.logs.access='tail -250f /usr/local/etc/nginx/logs/access.log'
alias nginx.logs.default.access='tail -250f /usr/local/etc/nginx/logs/default.access.log'
alias nginx.logs.default-ssl.access='tail -250f /usr/local/etc/nginx/logs/default-ssl.access.log'
alias nginx.logs.phpmyadmin.error='tail -250f /usr/local/etc/nginx/logs/phpmyadmin.error.log'
alias nginx.logs.phpmyadmin.access='tail -250f /usr/local/etc/nginx/logs/phpmyadmin.access.log'
alias nginx.logs.media.error='tail -250f /usr/local/etc/nginx/logs/media.error.log'
alias nginx.logs.media.access='tail -250f /usr/local/etc/nginx/logs/media.access.log'
# カラーのテスト出力
alias color="echo -e '
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
状態番号
\033[00m デフォルト状態 00 \033[00m
\033[01m 強調 01 \033[00m
\033[04m 下線 04 \033[00m
\033[05m 点滅 05 \033[00m
\033[07m 色反転 07 \033[00m
\033[08m 塗りつぶし 08 \033[00m(塗りつぶし 08)
色番号
\033[30m 黒 30 \033[00m \033[40m 40 \033[00m \033[31;40m 31;40 \033[00m \033[32;00;40m 32;00;40 \033[00m
\033[31m 赤 31 \033[00m \033[41m 41 \033[00m \033[32;41m 32;41 \033[00m \033[33;01;41m 33;01;41 \033[00m
\033[32m 緑 32 \033[00m \033[42m 42 \033[00m \033[33;42m 33;42 \033[00m \033[34;04;42m 34;04;42 \033[00m
\033[33m 黄(または茶) 33 \033[00m \033[43m 43 \033[00m \033[34;43m 34;43 \033[00m \033[35;05;43m 35;05;43 \033[00m
\033[34m 青 34 \033[00m \033[44m 44 \033[00m \033[35;44m 35;44 \033[00m \033[36;07;44m 36;07;44 \033[00m
\033[35m 紫 35 \033[00m \033[45m 45 \033[00m \033[36;45m 36;45 \033[00m \033[37;00;45m 37;00;45 \033[00m
\033[36m シアン 36 \033[00m \033[46m 46 \033[00m \033[37;46m 37;46 \033[00m \033[30;01;46m 30;01;46 \033[00m
\033[37m 白(またはグレー) 37 \033[00m \033[47m 47 \033[00m \033[30;47m 30;47 \033[00m \033[31;04;47m 31;04;47 \033[00m
'"
# カレントディレクトリ以下の .DS_Store をすべて削除
alias dsstore='find . -name ".DS_Store" -print -exec rm {} ";"'
# クリア
alias c="clear"
# 終了
alias x="exit"
# 全履歴の一覧を出力
function history-all { history -E 1 }
# 削除コマンドをゴミ箱に移動へ変更
function rm() {
if [ -d ~/.Trash ]; then
local DATE=`date "+%y%m%d-%H%M%S"`
mkdir ~/.Trash/$DATE
for i in $@; do
if [ -e $i ]; then
mv $i ~/.Trash/$DATE/
fi
done
else
/bin/rm $@
fi
}
# rsync (同期)
alias rsyncj='rsync --iconv=UTF-8-MAC,UTF-8 --progress --stats --recursive --times --human-readable --verbose --exclude="_____padding*" --exclude="*.DS_Store" --exclude="*.url"'
alias rsyncja='rsync --iconv=UTF-8-MAC,UTF-8 --progress --stats --recursive --dry-run --times --human-readable --verbose --checksum'
# 引数の検索ワードでGoogle検索をする
function google() {
local str opt
if [ $# != 0 ]; then # 引数が存在すれば
for i in $*; do
str="$str+$i"
done
str=`echo $str | sed 's/^\+//'` #先頭の「+」を削除
opt='search?num=50&hl=ja&ie=euc-jp&oe=euc-jp&lr=lang_ja'
opt="${opt}&q=${str}"
fi # 引数がなければ $opt は空になる
open http://www.google.co.jp/$opt # 標準ブラウザ
# w3m http://www.google.co.jp/$opt # w3m
# mozilla -remote openURL\(http::/www.google.co.jp/$opt\) # Firefox(未テスト)
}
alias ggl=google
# 乃木坂関連のダウンロード
function nogizaka() {
## 公式ブログ
cd '/data/source/Ruby/blog46' && ruby crawler.rb
## YouTube
nogi_movie yt 'https://www.youtube.com/channel/UCUzpZpX2wRYOk3J8QTFGxDg' # 乃木坂46 オフィシャルチャンネル
nogi_movie yt 'https://www.youtube.com/channel/UCmr9bYmymcBmQ1p2tLBRvwg' # 欅坂46 オフィシャルチャンネル
nogi_movie yt 'https://www.youtube.com/channel/UCOqX3MAAT4tlKKU08R3p4_w' # Special Week
nogi_movie yt 'https://www.youtube.com/channel/UChR9ikEDuGLQmiHsdBVkJ7w' # Special Week 2
nogi_movie yt 'https://www.youtube.com/channel/UCUnmEryXZ0JOkiMEGkVGo8Q' # Special Week new
nogi_movie yt 'https://www.youtube.com/channel/UCsb5E7kkR3VTOH7w-BQvy5w' # Tenshiken
nogi_movie yt 'https://www.youtube.com/playlist?list=PLMI6bbGtBIF3RpjOZqOLHGE9obG1Abq_e' # あとで保存
nogi_movie yt 'https://www.youtube.com/playlist?list=PLMI6bbGtBIF2uHcGsfav32glcljajKgLn' # テレビ出演
nogi_movie yt 'https://www.youtube.com/playlist?list=PLMI6bbGtBIF36WrB_1mBR3OrZcpHQLMq5' # 西野七瀬
nogi_movie yts 'nonno(search_七瀬)' nonno '七瀬' # 七瀬nonno
nogi_movie yts 'B.L.T.(search_乃木坂)' TokyoNewsService '乃木坂' # 乃木坂B.L.T.
nogi_movie yt 'http://www.dailymotion.com/akb48movie' # DM / AKB48 乃木坂46 channel
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment