From f52cf9aa9c5dce6bd510501c52ba0ed979a646a6 Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Sat, 30 Mar 2024 21:42:04 +0900 Subject: [PATCH 1/3] use XDG base directories --- bin/deploy-config-files | 8 ++++- config/.config/fzf/config | 7 +++++ config/.config/irb/irbrc | 4 +++ config/.config/irb/irbrc_history | 1 + config/{.ripgreprc => .config/ripgrep/config} | 0 config/.config/zsh/.zshrc | 8 +++-- config/.config/zsh/legacy/exports.zsh | 31 +++++++++++++------ config/.zshenv | 8 ++--- 8 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 config/.config/fzf/config create mode 100644 config/.config/irb/irbrc create mode 100644 config/.config/irb/irbrc_history rename config/{.ripgreprc => .config/ripgrep/config} (100%) diff --git a/bin/deploy-config-files b/bin/deploy-config-files index 8e19c4b1..21d4080d 100755 --- a/bin/deploy-config-files +++ b/bin/deploy-config-files @@ -25,11 +25,17 @@ mkdir -p ~/.config mkdir -p ~/.config/tmux ./bin/ln-idempotently ./config/.config/tmux/tmux.base.conf ~/.config/tmux/tmux.base.conf +# ruby +./bin/ln-idempotently ./config/.config/irb ~/.config/irb + # alacritty ./bin/ln-idempotently ./config/.config/alacritty ~/.config/alacritty # karabiner ./bin/ln-idempotently ./config/.config/karabiner ~/.config/karabiner +# fzf +./bin/ln-idempotently ./config/.config/fzf ~/.config/fzf + # ripgrep -./bin/ln-idempotently ./config/.ripgreprc ~/.ripgreprc +./bin/ln-idempotently ./config/.config/ripgrep ~/.config/ripgrep diff --git a/config/.config/fzf/config b/config/.config/fzf/config new file mode 100644 index 00000000..962f2510 --- /dev/null +++ b/config/.config/fzf/config @@ -0,0 +1,7 @@ +--height 40% +--layout=reverse +--border + +--color=dark +--color=fg:-1,bg:-1,hl:#95c4ce,fg+:-1,bg+:-1,hl+:#e9b189 +--color=info:#a093c7,prompt:#89bac2,pointer:#ada0d3,marker:#ada0d3,spinner:#ada0d3 diff --git a/config/.config/irb/irbrc b/config/.config/irb/irbrc new file mode 100644 index 00000000..2af3e4ea --- /dev/null +++ b/config/.config/irb/irbrc @@ -0,0 +1,4 @@ +IRB.conf[:SAVE_HISTORY] ||= 1000 +history_dir = File.join(ENV["XDG_DATA_HOME"], "irb", "history") +Dir.mkdir(history_dir) +IRB.conf[:HISTORY_FILE] ||= File.join(history_dir, "history") diff --git a/config/.config/irb/irbrc_history b/config/.config/irb/irbrc_history new file mode 100644 index 00000000..a3abe509 --- /dev/null +++ b/config/.config/irb/irbrc_history @@ -0,0 +1 @@ +exit diff --git a/config/.ripgreprc b/config/.config/ripgrep/config similarity index 100% rename from config/.ripgreprc rename to config/.config/ripgrep/config diff --git a/config/.config/zsh/.zshrc b/config/.config/zsh/.zshrc index ec3a9034..2d88960f 100644 --- a/config/.config/zsh/.zshrc +++ b/config/.config/zsh/.zshrc @@ -46,7 +46,9 @@ setopt interactive_comments setopt extended_glob # ---- Histroy ---- -HISTFILE="${ZDOTDIR}/.zsh_history" +mkdir -p "$XDG_STATE_HOME"/zsh "$XDG_CACHE_HOME"/zsh + +HISTFILE="$XDG_STATE_HOME"/zsh/history HISTSIZE=10000 # メモリに保存される履歴の件数 SAVEHIST=1000000 # 保存される履歴の件数 # https://github.com/rothgar/mastering-zsh/blob/921766e642bcf02d0f1be8fc57d0159a867299b0/docs/config/history.md @@ -69,6 +71,7 @@ zstyle ':chpwd:*' recent-dirs-max 5000 zstyle ':chpwd:*' recent-dirs-default yes zstyle ':chpwd:*' recent-dirs-prune 'parent' zstyle ':completion:*' recent-dirs-insert both +zstyle ':completion:*' cache-path $XDG_CACHE_HOME/zsh/zcompcache # cdしたあとで、自動的に ls する function chpwd() { ls } @@ -88,4 +91,5 @@ 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 +autoload -Uz compinit +compinit -C -d $XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION diff --git a/config/.config/zsh/legacy/exports.zsh b/config/.config/zsh/legacy/exports.zsh index 779953e5..2c248ed0 100644 --- a/config/.config/zsh/legacy/exports.zsh +++ b/config/.config/zsh/legacy/exports.zsh @@ -17,10 +17,28 @@ export PATH=$HOME/bin:$PATH export PATH=$HOME/.bin:$PATH # Go -export GOPATH=$HOME -export GOBIN=$GOPATH/gobin +export GOPATH="$XDG_DATA_HOME"/go +export GOMODCACHE="$XDG_CACHE_HOME"/go/mod +export GOBIN=$HOME/gobin export PATH=$GOBIN:$PATH +# Node.js +export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history + +# Ruby +export IRBRC="$XDG_CONFIG_HOME"/irb/irbrc + +# MySQL +export MYSQL_HISTFILE="$XDG_DATA_HOME"/mysql_history + +# PostgreSQL +export PSQL_HISTORY="$XDG_STATE_HOME"/psql_history + +# Redis +mkdir -p "$XDG_DATA_HOME"/redis +export REDISCLI_HISTFILE="$XDG_DATA_HOME"/redis/rediscli_history +export REDISCLI_RCFILE="$XDG_CONFIG_HOME"/redis/redisclirc + # Rancher Desktop export PATH=$HOME/.rd/bin:$PATH @@ -29,15 +47,10 @@ export PATH=/nix/var/nix/profiles/default/bin:$PATH export PATH=$HOME/.nix-profile/bin:$PATH # fzf -export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border' -export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS' ---color=dark ---color=fg:-1,bg:-1,hl:#95c4ce,fg+:-1,bg+:-1,hl+:#e9b189 ---color=info:#a093c7,prompt:#89bac2,pointer:#ada0d3,marker:#ada0d3,spinner:#ada0d3 -' +export FZF_DEFAULT_OPTS_FILE="$XDG_CONFIG_HOME"/fzf/config # ripgrep -export RIPGREP_CONFIG_PATH="$HOME/.ripgreprc" +export RIPGREP_CONFIG_PATH="$XDG_CONFIG_HOME"/ripgrep/config # git case "$(uname)" in diff --git a/config/.zshenv b/config/.zshenv index da455de4..6a66eb85 100644 --- a/config/.zshenv +++ b/config/.zshenv @@ -2,7 +2,7 @@ setopt no_global_rcs # disable path helper export ZDOTDIR="$HOME"/.config/zsh -export XDG_CONFIG_HOME="$HOME"/.config -export XDG_CACHE_HOME="$HOME"/.cache -export XDG_DATA_HOME="$HOME"/.local/share -export XDG_STATE_HOME="$HOME"/.local/state +export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:="$HOME/.config"} +export XDG_CACHE_HOME=${XDG_CACHE_HOME:="$HOME/.cache"} +export XDG_DATA_HOME=${XDG_DATA_HOME:="$HOME/.local/share"} +export XDG_STATE_HOME=${XDG_STATE_HOME:="$HOME/.local/state"} From 9d6956a3516db8032baa6f3ac7da19054d111d49 Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Sat, 30 Mar 2024 21:50:23 +0900 Subject: [PATCH 2/3] tweak --- config/.config/zsh/.zshrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/.config/zsh/.zshrc b/config/.config/zsh/.zshrc index 2d88960f..e19a899d 100644 --- a/config/.config/zsh/.zshrc +++ b/config/.config/zsh/.zshrc @@ -70,8 +70,9 @@ 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 ':chpwd:*' recent-dirs-file "$XDG_CACHE_HOME"/zsh/chpwd-recent-dirs zstyle ':completion:*' recent-dirs-insert both -zstyle ':completion:*' cache-path $XDG_CACHE_HOME/zsh/zcompcache +zstyle ':completion:*' cache-path "$XDG_CACHE_HOME"/zsh/zcompcache # cdしたあとで、自動的に ls する function chpwd() { ls } From 5229d0955f35f5cbddd245b8a3854854c2ca4052 Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Sat, 30 Mar 2024 21:50:29 +0900 Subject: [PATCH 3/3] update .gitignore --- .gitignore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index 6971a961..9df3bb19 100644 --- a/.gitignore +++ b/.gitignore @@ -16,10 +16,5 @@ /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