Skip to content

Commit

Permalink
Stop using nix for zsh configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
izumin5210 committed Mar 30, 2024
1 parent bfe2a80 commit 7d0776a
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 204 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@
/config/.config/karabiner/*
!/config/.config/karabiner/karabiner.json

# zsh
/config/.config/zsh/.chpwd-recent-dirs
/config/.config/zsh/.zcompdump
/config/.config/zsh/.zsh_history

# Nix
/result
10 changes: 2 additions & 8 deletions bin/deploy-config-files
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ mkdir -p ~/.config
./bin/ln-idempotently ./config/.config/gh ~/.config/gh

# zsh
mkdir -p ~/.config/zsh
./bin/ln-idempotently ./config/.config/zsh/legacy ~/.config/zsh/legacy
./bin/ln-idempotently ./config/.zshenv ~/.zshenv
./bin/ln-idempotently ./config/.config/zsh ~/.config/zsh
./bin/ln-idempotently ./config/.config/starship.toml ~/.config/starship.toml

# vim
Expand All @@ -32,9 +32,3 @@ mkdir -p ~/.config/tmux

# ripgrep
./bin/ln-idempotently ./config/.ripgreprc ~/.ripgreprc

if [ "${CODESPACES:-"false"}" = "true" ]; then
# overwrite default zsh configurations
cp ./codespaces/config/.zshrc ~/.zshrc
cp ./codespaces/config/.zshenv ~/.zshenv
fi
1 change: 0 additions & 1 deletion codespaces/config/.zshenv

This file was deleted.

1 change: 0 additions & 1 deletion codespaces/config/.zshrc

This file was deleted.

89 changes: 89 additions & 0 deletions config/.config/zsh/.zshrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
source $HOME/.config/zsh/legacy/exports.zsh
source $HOME/.config/zsh/legacy/aliases.zsh

bindkey -e # emacs emulation
autoload -Uz add-zsh-hook

ulimit -u 2048
ulimit -n 16384

# Zsh options
# ================================================================
REPORTTIME=3

setopt correct
setopt interactive_comments
setopt extended_glob

# ---- Histroy ----
HISTFILE="${ZDOTDIR}/.zsh_history"
HISTSIZE=10000 # メモリに保存される履歴の件数
SAVEHIST=1000000 # 保存される履歴の件数
# https://github.com/rothgar/mastering-zsh/blob/921766e642bcf02d0f1be8fc57d0159a867299b0/docs/config/history.md
setopt EXTENDED_HISTORY # Write the history file in the ':start:elapsed;command' format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire a duplicate event first when trimming history.
setopt HIST_IGNORE_DUPS # Do not record an event that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete an old recorded event if a new event is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a previously found event.
setopt HIST_IGNORE_SPACE # Do not record an event starting with a space.
setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file.
setopt HIST_VERIFY # Do not execute immediately upon history expansion.
setopt APPEND_HISTORY # append to history file
setopt HIST_NO_STORE # Don't store history commands

autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
zstyle ':chpwd:*' recent-dirs-max 5000
zstyle ':chpwd:*' recent-dirs-default yes
zstyle ':chpwd:*' recent-dirs-prune 'parent'
zstyle ':completion:*' recent-dirs-insert both

# cdしたあとで、自動的に ls する
function chpwd() { ls }

# ---- Directory stack ----
setopt auto_cd # ディレクトリ名を入力したら自動でcd
setopt auto_pushd # ディレクトリスタックに追加(`cd +<Tab>`で履歴表示)
setopt pushd_ignore_dups # pushd時にすでにスタックに含まれてた場合は追加しない
DIRSTACKSIZE=100 # ディレクトリスタック保存件数

# ---- Completion ----
if [ -d "$HOME/.nix-profile/share/zsh/site-functions" ]; then
fpath=($HOME/.nix-profile/share/zsh/site-functions $fpath)
fi

setopt auto_menu # 補完候補が複数あるときに自動的に一覧表示
bindkey "^[[Z" reverse-menu-complete # Shift-Tabで補完候補を逆順する("\e[Z"でも動作する)
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # 補完時に大文字小文字を区別しない

autoload -Uz compinit; compinit -C

# Load plugins
# ================================================================
source $HOME/.config/zsh/legacy/functions.zsh
source $HOME/.config/zsh/legacy/fzf.zsh

# direnv
if type direnv > /dev/null 2>&1; then
eval "$(direnv hook zsh)"
fi

# fnm (Node.js)
if type fnm >/dev/null 2>&1; then
eval "$(fnm env --use-on-cd --log-level error)"
fi

# 1Password
if [ -d "${HOME}/.config/op/plugins.sh" ]; then
source "${HOME}/.config/op/plugins.sh"
fi

# Orbstack
if [ -f "${HOME}/.orbstack/shell/init.zsh" ]; then
source "${HOME}/.orbstack/shell/init.zsh"
fi

# Starship
eval "$(starship init zsh)"
60 changes: 0 additions & 60 deletions config/.config/zsh/legacy/.zshenv

This file was deleted.

81 changes: 0 additions & 81 deletions config/.config/zsh/legacy/.zshrc

This file was deleted.

6 changes: 0 additions & 6 deletions config/.config/zsh/legacy/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@ fi
alias history='history -E'

alias mkdir='mkdir -p'
alias be='bundle exec'

alias gsed=sed

# `hub` has implemented `pr` and `sync` subcommands. they are conflicted with self-defined commands.
# alias git='hub'

if [[ -x `which colordiff` ]]; then
alias diff='colordiff -u'
else
alias diff='diff -u'
fi

alias ew='envchain wtd'

alias mw="docker compose -f /Users/izumin/.bin/compose.mw.yaml"
44 changes: 10 additions & 34 deletions config/.config/zsh/legacy/exports.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,23 @@ export TERM=xterm-256color
# path
# ================================================================

export DEFAULT_PREFIX="${HOMEBREW_PREFIX:-"${HOME}/.local"}"

if [ -n "$HOMEBREW_PREFIX" ]; then
export PATH=$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:${PATH}
export MANPATH=$HOMEBREW_PREFIX/opt/coreutils/libexec/gnuman:${MANPATH}
fi

export PATH="${HOMEBREW_PREFIX}/bin:${PATH}"
export PATH="${HOME}/.local/bin:${PATH}"
export PATH="/usr/local/bin:${PATH}"
export PATH=$HOME/bin:$PATH
export PATH=$HOME/.bin:$PATH

# yarn
export PATH="$HOME/.config/yarn/global/node_modules/.bin:$PATH"
export PATH="$HOME/.yarn/bin:$PATH"

# golang
# Go
export GOPATH=$HOME
export GOBIN=$GOPATH/gobin

# rust
export PATH=$HOME/.cargo/bin:$PATH

# android
export ANDROID_SDK_ROOT=$HOMEBREW_PREFIX/share/android-sdk
export ANDROID_SDK_TOOLS=$ANDROID_SDK_ROOT/tools
export ANDROID_SDK_PLATFORM_TOOLS=$ANDROID_SDK_ROOT/platform-tools
export ANDROID_HOME=$ANDROID_SDK_ROOT
export PATH=$GOBIN:$PATH

# Rancher Desktop
export PATH=$HOME/.rd/bin:$PATH

# path
export PATH=$HOME/bin:$PATH
export PATH=$HOME/.bin:$PATH
export PATH=$RBENV_ROOT/bin:$PATH
export PATH=$PYENV_ROOT/bin:$PATH
export PATH=$GOBIN:$PATH
export PATH=$ANDROID_SDK_TOOLS:$ANDROID_SDK_PLATFORM_TOOLS:$PATH
export PATH=$POSTGRESAPP_ROOT/bin:$PATH
# nix
# Nix
export PATH=/nix/var/nix/profiles/default/bin:$PATH
export PATH=$HOME/.nix-profile/bin:$PATH

# Tools in wantedly
export PATH=$HOME/.wantedly/bin:$PATH

# fzf
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS'
Expand All @@ -79,4 +50,9 @@ case "$(uname)" in
;;
esac

if [ -d "$HOME/.nix-profile/share/git/contrib/diff-highlight" ];then
export PATH="$HOME/.nix-profile/share/git/contrib/diff-highlight:$PATH"
fi

# LayerX
export GOPRIVATE=github.com/LayerXcom/
3 changes: 3 additions & 0 deletions config/.zshenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setopt no_global_rcs # disable path helper

export ZDOTDIR="${HOME}/.config/zsh"
15 changes: 2 additions & 13 deletions home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
pkgs.fnm

# other langs
pkgs.ruby
pkgs.php
pkgs.ruby

# git
pkgs.git
Expand All @@ -48,6 +48,7 @@
pkgs.neovim

# zsh
pkgs.zsh
pkgs.sheldon

# tmux
Expand Down Expand Up @@ -119,18 +120,6 @@
};

programs= {
zsh = {
enable = true;
enableCompletion = true;
dotDir = ".config/zsh";
initExtra = ''
source $HOME/.config/zsh/legacy/.zshrc
'';
envExtra = ''
source $HOME/.config/zsh/legacy/.zshenv
PATH=${pkgs.git}/share/git/contrib/diff-highlight:$PATH
'';
};
tmux = {
enable = true;
extraConfig = ''
Expand Down

0 comments on commit 7d0776a

Please sign in to comment.