Skip to content

Commit

Permalink
Merge pull request #302 from izumin5210/izumin5210/xdg
Browse files Browse the repository at this point in the history
use XDG based directory
  • Loading branch information
izumin5210 authored Mar 30, 2024
2 parents 39d2497 + 5229d09 commit 89f72a4
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 21 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion bin/deploy-config-files
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions config/.config/fzf/config
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions config/.config/irb/irbrc
Original file line number Diff line number Diff line change
@@ -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")
1 change: 1 addition & 0 deletions config/.config/irb/irbrc_history
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exit
File renamed without changes.
9 changes: 7 additions & 2 deletions config/.config/zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -68,7 +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

# cdしたあとで、自動的に ls する
function chpwd() { ls }
Expand All @@ -88,4 +92,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
31 changes: 22 additions & 9 deletions config/.config/zsh/legacy/exports.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions config/.zshenv
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

0 comments on commit 89f72a4

Please sign in to comment.