Skip to content

Instantly share code, notes, and snippets.

@Hikali-47041
Last active September 7, 2023 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hikali-47041/6f93b585dc80e023553417060bc97cd0 to your computer and use it in GitHub Desktop.
Save Hikali-47041/6f93b585dc80e023553417060bc97cd0 to your computer and use it in GitHub Desktop.
zshrc
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1024
SAVEHIST=1024
setopt autocd beep notify
# End of lines configured by zsh-newuser-install
# AUTO_MENUを使う
setopt MENU_COMPLETE
# コマンドラインの引数で --prefix=/usr などの = 以降でも補完できる
setopt magic_equal_subst
## 環境変数補完
setopt AUTO_PARAM_KEYS
# 語の途中でもカーソル位置で補完
setopt complete_in_word
# cd -<tab>で以前移動したディレクトリを表示
setopt auto_pushd
# 日本語ファイル名を表示可能にする
setopt print_eight_bit
# スペルミス訂正
setopt correct
# コマンドラインでも # 以降をコメントと見なす
setopt interactive_comments
# 同時に起動したzshの間でヒストリを共有する
setopt share_history
# 矢印キーのインターフェイスを使って自動補完する
zstyle ':completion:*' menu select
# 補完メッセージを読みやすくする
zstyle ':completion:*' verbose yes
zstyle ':completion:*' format '%B%d%b'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*' group-name ''
### キーバインド - - -
## DELETE key
bindkey "^[[3~" delete-char
## HOME key
bindkey "^[[H" beginning-of-line
## END key
bindkey "^[[F" end-of-line
### alias
alias ls='ls --color=auto'
alias ll='ls -alhGp --time-style=iso'
#### progress
alias cp='cp -vi'
alias mv='mv -vi'
#### colorfulalias
alias diff='diff --color=auto'
alias grep='grep --color=auto'
alias ip='ip -color=auto'
#### rm to mv -> /tmp
rmtmp(){
# 削除先を /tmp/trash に
TRASH_DIR=/tmp/trash
# 引数がない際に usage を出力
if [ $# -eq 0 ]
then
echo "missing operand. usage: $0 file ..."
return 0
fi
# 保存先 : 日付別に
dst_dir="$TRASH_DIR"/trash_$(date +%F_%H-%M-%S)
# ディレクトリがなければ作る
[ ! -e dst_dir ] && mkdir -p "$dst_dir"
# すべてのファイルに対して
for file in "$@"
do
# オプション引数 -* を無視
if [[ "$file" = -* ]]
then
shift
continue
fi
# ファイルが存在しない場合
if [ ! -e "$file" ]
then
echo "$0: $file: No such file or directory"
return 1
fi
# echo "$file -> $dst_dir"
# 移動
mv "$file" "$dst_dir"
done
}
#### rmした際にmvtmpに移動させる。
alias rm='rmtmp'
### zi (zinit)
if [[ ! -f $HOME/.zi/bin/zi.zsh ]]; then
print -P "%F{33}▓▒░ %F{160}Installing (%F{33}z-shell/zi%F{160})…%f"
command mkdir -p "$HOME/.zi" && command chmod g-rwX "$HOME/.zi"
command git clone -q --depth=1 --branch "main" https://github.com/z-shell/zi "$HOME/.zi/bin" && \
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
print -P "%F{160}▓▒░ The clone has failed.%f%b"
fi
source "$HOME/.zi/bin/zi.zsh"
autoload -Uz _zi
(( ${+_comps} )) && _comps[zi]=_zi
# examples here -> https://z-shell.pages.dev/docs/gallery/collection
zicompinit # <- https://z-shell.pages.dev/docs/gallery/collection#minimal
#### zi addons
## シンタックスハイライト
zi light zsh-users/zsh-syntax-highlighting
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern regexp) # ハイライト対象
### はいらいとからー
ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=198,bold' # unknown tokens / errors
ZSH_HIGHLIGHT_STYLES[command]='fg=045' # command
ZSH_HIGHLIGHT_STYLES[builtin]='fg=081' # buildin command
ZSH_HIGHLIGHT_STYLES[alias]='fg=075' # alias
## 履歴補完
zi light zsh-users/zsh-autosuggestions
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=067' # 表示色の設定
# p10k
zi ice depth=1; zi light romkatv/powerlevel10k
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# user installed bin のパス
export PATH=$HOME/.local/bin:$PATH
# cf. color charts
# https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg
# pnpm
export PNPM_HOME="/home/hikali/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment