<commit_before>#
# .zshrc - Zsh configuration
#


function load() {
  [ -f $1 ] && source $1
}

export LANG=ja_JP.UTF-8
export LC_CTYPE=ja_JP.UTF-8

export EDITOR=nvim
export XDG_CONFIG_HOME=$HOME/.config
export PATH=$PATH:/usr/texbin
export PATH=$PATH:$HOME/.dotfiles/bin
export PYTHONDONTWRITEBYTECODE=1
export PYENV_ROOT=$HOME/.pyenv


# secret
load $HOME/.dotfiles/private/private.zsh


# autoloads
autoload -Uz colors; colors
autoload -Uz zmv
autoload -Uz vcs_info
autoload -Uz add-zsh-hook
autoload -Uz is-at-least
autoload -U compinit; compinit


# generals
case ${OSTYPE} in
  darwin*)
    export PATH=/usr/local/bin:$PATH
    export PATH=/usr/local/sbin:$PATH
    export PATH=$HOME/.local/bin:$PATH
    export MECAB_PATH=$(brew --prefix)/lib/libmecab.dylib
    ;;
  linux*)
    # for ipython
    export QT_QPA_PLATFORM='offscreen'

    export PATH=$PATH:/usr/local/sbin
    export PATH=$HOME/.local/bin:$PATH
    export PATH=$HOME/.linuxbrew/bin:$PATH
    export PATH=$HOME/.linuxbrew/sbin:$PATH

    export PATH=/usr/local/cuda/bin:$PATH
    export CPATH=/usr/local/cuda/include:$CPATH
    export LIBRARY_PATH=/usr/local/cuda/lib64:$LIBRARY_PATH
    export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
    ;;
esac


# etc
eval "$(rbenv init -)"
eval "$(pyenv init -)"
if which pyenv-virtualenv-init > /dev/null; then
  eval "$(pyenv virtualenv-init -)"
fi


# brew home
export BREW_HOME=$(brew --prefix)


# zstyles
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*:default' menu select=1


# options
setopt auto_cd correct
setopt APPEND_HISTORY INC_APPEND_HISTORY SHARE_HISTORY
setopt extended_history share_history
setopt hist_ignore_all_dups HIST_IGNORE_SPACE
setopt auto_param_slash
setopt mark_dirs
setopt list_types
setopt auto_menu
setopt auto_param_keys
setopt interactive_comments
setopt magic_equal_subst
setopt complete_in_word
setopt print_eight_bit
setopt extended_glob
setopt globdots
setopt auto_list
setopt no_beep
setopt no_flow_control
setopt magic_equal_subst
setopt auto_menu
setopt extended_glob
setopt prompt_subst


# colorscheme
if [ "$COLORTERM" = "gnome-terminal" ] || [ "$COLORTERM" = "xfce4-terminal" ]; then
  export TERM=xterm-256color
elif [ "$COLORTERM" = "rxvt-xpm" ]; then
  export TERM=rxvt-256color
fi


# check whether tmux exists
if builtin command -v tmux > /dev/null; then
  if [ -z $TMUX ]; then

    # check tmux sessions
    if $(tmux has-session); then
      tmux attach
    else
      tmux
    fi
  fi
fi


# peco
function peco-history-selection() {
    case ${OSTYPE} in
      darwin*)
        BUFFER=`history -n 1 | tail -r  | awk '!a[$0]++' | peco`
        ;;
      linux*)
        BUFFER=`history -n 1 | tac  | awk '!a[$0]++' | peco`
        ;;
    esac
    CURSOR=$#BUFFER
    zle reset-prompt
}


function peco-change-dir() {
    selected_dir=$(find . -type d | grep -v .git | peco --prompt "[Change dir]")
    if [ -n "$selected_dir" ]; then
        BUFFER="cd ${selected_dir}"
        zle accept-line
    fi
    zle redisplay
}


# register custom functions
zle -N peco-change-dir
zle -N peco-history-selection


# bindkeys
bindkey -e
bindkey '^R' peco-history-selection
bindkey '^K' peco-change-dir


# history
HISTFILE=$HOME/.zsh-history
HISTSIZE=100000
SAVEHIST=100000


# aliases
case ${OSTYPE} in
  darwin*)
    alias ls="ls -G -F"
    ;;
  linux*)
    alias ls="ls --color=auto"
    ;;
esac

alias l="ls"
alias la="ls -a"
alias lla="ls -la"<commit_msg>add reverse option for tab completion<commit_after>#
# .zshrc - Zsh configuration
#


function load() {
  [ -f $1 ] && source $1
}

export LANG=ja_JP.UTF-8
export LC_CTYPE=ja_JP.UTF-8

export EDITOR=nvim
export XDG_CONFIG_HOME=$HOME/.config
export PATH=$PATH:/usr/texbin
export PATH=$PATH:$HOME/.dotfiles/bin
export PYTHONDONTWRITEBYTECODE=1
export PYENV_ROOT=$HOME/.pyenv


# secret
load $HOME/.dotfiles/private/private.zsh


# autoloads
autoload -Uz colors; colors
autoload -Uz zmv
autoload -Uz vcs_info
autoload -Uz add-zsh-hook
autoload -Uz is-at-least
autoload -U compinit; compinit


# generals
case ${OSTYPE} in
  darwin*)
    export PATH=/usr/local/bin:$PATH
    export PATH=/usr/local/sbin:$PATH
    export PATH=$HOME/.local/bin:$PATH
    export MECAB_PATH=$(brew --prefix)/lib/libmecab.dylib
    ;;
  linux*)
    # for ipython
    export QT_QPA_PLATFORM='offscreen'

    export PATH=$PATH:/usr/local/sbin
    export PATH=$HOME/.local/bin:$PATH
    export PATH=$HOME/.linuxbrew/bin:$PATH
    export PATH=$HOME/.linuxbrew/sbin:$PATH

    export PATH=/usr/local/cuda/bin:$PATH
    export CPATH=/usr/local/cuda/include:$CPATH
    export LIBRARY_PATH=/usr/local/cuda/lib64:$LIBRARY_PATH
    export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
    ;;
esac


# etc
eval "$(rbenv init -)"
eval "$(pyenv init -)"
if which pyenv-virtualenv-init > /dev/null; then
  eval "$(pyenv virtualenv-init -)"
fi


# brew home
export BREW_HOME=$(brew --prefix)


# zstyles
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*:default' menu select=1


# options
setopt auto_cd correct
setopt APPEND_HISTORY INC_APPEND_HISTORY SHARE_HISTORY
setopt extended_history share_history
setopt hist_ignore_all_dups HIST_IGNORE_SPACE
setopt auto_param_slash
setopt mark_dirs
setopt list_types
setopt auto_menu
setopt auto_param_keys
setopt interactive_comments
setopt magic_equal_subst
setopt complete_in_word
setopt print_eight_bit
setopt extended_glob
setopt globdots
setopt auto_list
setopt no_beep
setopt no_flow_control
setopt magic_equal_subst
setopt auto_menu
setopt extended_glob
setopt prompt_subst


# colorscheme
if [ "$COLORTERM" = "gnome-terminal" ] || [ "$COLORTERM" = "xfce4-terminal" ]; then
  export TERM=xterm-256color
elif [ "$COLORTERM" = "rxvt-xpm" ]; then
  export TERM=rxvt-256color
fi


# check whether tmux exists
if builtin command -v tmux > /dev/null; then
  if [ -z $TMUX ]; then

    # check tmux sessions
    if $(tmux has-session); then
      tmux attach
    else
      tmux
    fi
  fi
fi


# peco
function peco-history-selection() {
    case ${OSTYPE} in
      darwin*)
        BUFFER=`history -n 1 | tail -r  | awk '!a[$0]++' | peco`
        ;;
      linux*)
        BUFFER=`history -n 1 | tac  | awk '!a[$0]++' | peco`
        ;;
    esac
    CURSOR=$#BUFFER
    zle reset-prompt
}


function peco-change-dir() {
    selected_dir=$(find . -type d | grep -v .git | peco --prompt "[Change dir]")
    if [ -n "$selected_dir" ]; then
        BUFFER="cd ${selected_dir}"
        zle accept-line
    fi
    zle redisplay
}


# register custom functions
zle -N peco-change-dir
zle -N peco-history-selection


# bindkeys
bindkey -e
bindkey '^R' peco-history-selection
bindkey '^K' peco-change-dir
bindkey "\e[Z" reverse-menu-complete


# history
HISTFILE=$HOME/.zsh-history
HISTSIZE=100000
SAVEHIST=100000


# aliases
case ${OSTYPE} in
  darwin*)
    alias ls="ls -G -F"
    ;;
  linux*)
    alias ls="ls --color=auto"
    ;;
esac

alias l="ls"
alias la="ls -a"
alias lla="ls -la"
{'fraction_non_alphanumeric': 0.1233682398508105, 'fraction_numerical': 0.00946779515134127, 'mean_word_length': 3.56282722513089, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2161279', 'n_tokens_mistral': 2807, 'n_tokens_neox': 2578, 'n_words': 617}