Skip to content

Instantly share code, notes, and snippets.

@ken5scal
Forked from mollifier/zshrc_useful.sh
Last active August 29, 2015 14:12
Show Gist options
  • Save ken5scal/17c0263b249b6b23a495 to your computer and use it in GitHub Desktop.
Save ken5scal/17c0263b249b6b23a495 to your computer and use it in GitHub Desktop.

Revisions

  1. @mollifier mollifier revised this gist Dec 21, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion zshrc_useful.sh
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ SAVEHIST=1000000
    # 1行表示
    # PROMPT="%~ %# "
    # 2行表示
    PROMPT="%{${fg[red]}%}[%n@%m]%{${reset_color}%} %~
    PROMPT="%{${fg[green]}%}[%n@%m]%{${reset_color}%} %~
    %# "


  2. @mollifier mollifier revised this gist Aug 31, 2014. 1 changed file with 8 additions and 7 deletions.
    15 changes: 8 additions & 7 deletions zshrc_useful.sh
    Original file line number Diff line number Diff line change
    @@ -57,16 +57,17 @@ zstyle ':completion:*:processes' command 'ps x -o pid,s,args'

    ########################################
    # vcs_info

    autoload -Uz vcs_info
    zstyle ':vcs_info:*' formats '(%s)-[%b]'
    zstyle ':vcs_info:*' actionformats '(%s)-[%b|%a]'
    precmd () {
    psvar=()
    autoload -Uz add-zsh-hook

    zstyle ':vcs_info:*' formats '%F{green}(%s)-[%b]%f'
    zstyle ':vcs_info:*' actionformats '%F{red}(%s)-[%b|%a]%f'

    function _update_vcs_info_msg() {
    LANG=en_US.UTF-8 vcs_info
    [[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_"
    RPROMPT="${vcs_info_msg_0_}"
    }
    RPROMPT="%1(v|%F{green}%1v%f|)"
    add-zsh-hook precmd _update_vcs_info_msg


    ########################################
  3. @mollifier mollifier revised this gist Aug 31, 2014. 1 changed file with 1 addition and 9 deletions.
    10 changes: 1 addition & 9 deletions zshrc_useful.sh
    Original file line number Diff line number Diff line change
    @@ -91,27 +91,18 @@ setopt auto_pushd
    # 重複したディレクトリを追加しない
    setopt pushd_ignore_dups

    # = の後はパス名として補完する
    setopt magic_equal_subst

    # 同時に起動したzshの間でヒストリを共有する
    setopt share_history

    # 同じコマンドをヒストリに残さない
    setopt hist_ignore_all_dups

    # ヒストリファイルに保存するとき、すでに重複したコマンドがあったら古い方を削除する
    setopt hist_save_nodups

    # スペースから始まるコマンド行はヒストリに残さない
    setopt hist_ignore_space

    # ヒストリに保存するときに余分なスペースを削除する
    setopt hist_reduce_blanks

    # 補完候補が複数あるときに自動的に一覧表示する
    setopt auto_menu

    # 高機能なワイルドカード展開を使用する
    setopt extended_glob

    @@ -165,6 +156,7 @@ case ${OSTYPE} in
    ;;
    linux*)
    #Linux用の設定
    alias ls='ls -F --color=auto'
    ;;
    esac

  4. @mollifier mollifier revised this gist May 17, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions zshrc_useful.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    # 少し凝った zshrc
    # License : MIT
    # http://mollifier.mit-license.org/

    ########################################
    # 環境変数
  5. @mollifier mollifier renamed this gist Feb 18, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. @mollifier mollifier revised this gist Feb 18, 2013. No changes.
  7. @mollifier mollifier created this gist Feb 18, 2013.
    169 changes: 169 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,169 @@
    # 少し凝った zshrc

    ########################################
    # 環境変数
    export LANG=ja_JP.UTF-8


    # 色を使用出来るようにする
    autoload -Uz colors
    colors

    # emacs 風キーバインドにする
    bindkey -e

    # ヒストリの設定
    HISTFILE=~/.zsh_history
    HISTSIZE=1000000
    SAVEHIST=1000000

    # プロンプト
    # 1行表示
    # PROMPT="%~ %# "
    # 2行表示
    PROMPT="%{${fg[red]}%}[%n@%m]%{${reset_color}%} %~
    %# "


    # 単語の区切り文字を指定する
    autoload -Uz select-word-style
    select-word-style default
    # ここで指定した文字は単語区切りとみなされる
    # / も区切りと扱うので、^W でディレクトリ1つ分を削除できる
    zstyle ':zle:*' word-chars " /=;@:{},|"
    zstyle ':zle:*' word-style unspecified

    ########################################
    # 補完
    # 補完機能を有効にする
    autoload -Uz compinit
    compinit

    # 補完で小文字でも大文字にマッチさせる
    zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

    # ../ の後は今いるディレクトリを補完しない
    zstyle ':completion:*' ignore-parents parent pwd ..

    # sudo の後ろでコマンド名を補完する
    zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \
    /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin

    # ps コマンドのプロセス名補完
    zstyle ':completion:*:processes' command 'ps x -o pid,s,args'


    ########################################
    # vcs_info

    autoload -Uz vcs_info
    zstyle ':vcs_info:*' formats '(%s)-[%b]'
    zstyle ':vcs_info:*' actionformats '(%s)-[%b|%a]'
    precmd () {
    psvar=()
    LANG=en_US.UTF-8 vcs_info
    [[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_"
    }
    RPROMPT="%1(v|%F{green}%1v%f|)"


    ########################################
    # オプション
    # 日本語ファイル名を表示可能にする
    setopt print_eight_bit

    # beep を無効にする
    setopt no_beep

    # フローコントロールを無効にする
    setopt no_flow_control

    # '#' 以降をコメントとして扱う
    setopt interactive_comments

    # ディレクトリ名だけでcdする
    setopt auto_cd

    # cd したら自動的にpushdする
    setopt auto_pushd
    # 重複したディレクトリを追加しない
    setopt pushd_ignore_dups

    # = の後はパス名として補完する
    setopt magic_equal_subst

    # 同時に起動したzshの間でヒストリを共有する
    setopt share_history

    # 同じコマンドをヒストリに残さない
    setopt hist_ignore_all_dups

    # ヒストリファイルに保存するとき、すでに重複したコマンドがあったら古い方を削除する
    setopt hist_save_nodups

    # スペースから始まるコマンド行はヒストリに残さない
    setopt hist_ignore_space

    # ヒストリに保存するときに余分なスペースを削除する
    setopt hist_reduce_blanks

    # 補完候補が複数あるときに自動的に一覧表示する
    setopt auto_menu

    # 高機能なワイルドカード展開を使用する
    setopt extended_glob

    ########################################
    # キーバインド

    # ^R で履歴検索をするときに * でワイルドカードを使用出来るようにする
    bindkey '^R' history-incremental-pattern-search-backward

    ########################################
    # エイリアス

    alias la='ls -a'
    alias ll='ls -l'

    alias rm='rm -i'
    alias cp='cp -i'
    alias mv='mv -i'

    alias mkdir='mkdir -p'

    # sudo の後のコマンドでエイリアスを有効にする
    alias sudo='sudo '

    # グローバルエイリアス
    alias -g L='| less'
    alias -g G='| grep'

    # C で標準出力をクリップボードにコピーする
    # mollifier delta blog : http://mollifier.hatenablog.com/entry/20100317/p1
    if which pbcopy >/dev/null 2>&1 ; then
    # Mac
    alias -g C='| pbcopy'
    elif which xsel >/dev/null 2>&1 ; then
    # Linux
    alias -g C='| xsel --input --clipboard'
    elif which putclip >/dev/null 2>&1 ; then
    # Cygwin
    alias -g C='| putclip'
    fi



    ########################################
    # OS 別の設定
    case ${OSTYPE} in
    darwin*)
    #Mac用の設定
    export CLICOLOR=1
    alias ls='ls -G -F'
    ;;
    linux*)
    #Linux用の設定
    ;;
    esac

    # vim:set ft=zsh: