1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

zsh zshenv zshrc

Last updated at Posted at 2020-06-17

zshの環境設定を書いておく

bashだけど必読。
Linux: .bashrcと.bash_profileの違いを今度こそ理解する|TechRacho(テックラッチョ)〜エンジニアの「?」を「!」に〜|BPS株式会社

注意
zshenv内のパス設定は出来るだけ文字列だけにする。
どうしてもクォーテーションで囲みたい時は変数展開出来るダブルクォーテーション。

aliasはシングルクォーテーションのみ。コマンドとして出力する為。

.zshenv
export ZDOTDIR=$HOME/.zsh
export HISTFILE=${HOME}/.zsh/.zsh_history

export LD_LIBRARY_PATH=/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/lib
#unset DYLD_LIBRARY_PATH
 
export LDFLAGS=-L/usr/local/lib
export LDFLAGS=-L/usr/local/stow/gettext-021/lib:$LDFLAGS
export LDFLAGS=-L/usr/local/stow/gettext-021/lib/gettext:$LDFLAGS

export CPPFLAGS=-I/usr/local/include
export CPPFLAGS=-I/usr/local/stow/gettext-021/include:$CPPFLAGS

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
 export PKG_CONFIG_PATH=/usr/local/stow/openssl/lib/pkgconfig:$PKG_CONFIG_PATH

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/bin
 export PATH=/usr/local/stow/gettext-021/bin:$PATH
 export PATH=/usr/local/stow/ruby/bin:$PATH # for execute gem
##  export PATH=/usr/X11/bin:/usr/local/sbin:$PATH
#export CONFIGURE_OPTS=--with-opt-dir=/usr/local/stow/openssl --with-readline-dir=/usr/local/stow/readline --enable-shared
#export SSL_CERT_FILE=/usr/local/stow/openssl/ssl/cert.pem

export MANPATH=/usr/local/share/man:/usr/share/man
#export MANPATH=/usr/share/man/ja_JP.UTF-8:$MANPATH
# /etc/man.conf
# export LD_RUN_PATH=/usr/local/lib:$LD_RUN_PATH
.zshrc
# --------
# ZSH
# --------
# 補完機能
autoload -Uz compinit
compinit
zstyle ':completion:*' menu select

# promptinit
# --------
# ZSH history
# --------
alias hi='history -90'
# 履歴ファイルの保存先
# export HISTFILE=${HOME}/.zsh_history
# メモリに保存される履歴の件数
export HISTSIZE=10000
# 履歴ファイルに保存される履歴の件数
export SAVEHIST=100000
# 直前と同じコマンドの場合は履歴に追加しない
#setopt hist_ignore_dups
# 重複するコマンドは古い法を削除する
#setopt hist_ignore_all_dups
# 開始と終了を記録
setopt EXTENDED_HISTORY
# 履歴を複数の端末で共有する
setopt share_history

# --------
# ZSH prompt
# --------
# promptinitを使う場合はこちらを読み込む
# 利用可能なpromptの設定を見る
# $ prompt -l
# promptを設定する
# $ prompt [prompt名]
# promptを独自で変更
# PROMPT='%m:%F{green}%c%f %n%# '
PROMPT='%F{yellow}%c%f $ '


# --------
# BASH ZSH 共通
# --------
umask 027
# ------
# EXPORT
# ------
export TZ=JST-9
export LC_TIME=ja_JP.UTF-8 #日時形式
#
export LANG=ja_JP.UTF-8
export LC_ALL=ja_JP.UTF-8
# ------
# # LANG=C
# ------
#export LANG=C
#export LC_ALL=C

# export LC_MESSAGES=ja_JP.UTF-8 #メッセージの言語
# export LC_CTYPE=ja_JP.UTF-8
# export OUTPUT_CHARSET=UTF-8
# NG? export OUTPUT_CHARSET=ja_JP.UTF-8
# export LDFLAGS='-L/usr/local/lib'
# export TERM='xterm-256color'
#


# ------
# vim neovim
# ------
export EDITOR=vim

if [ -f /usr/local/bin/vim ]; then
  alias vi=/usr/local/bin/vim
  alias vim=/usr/local/bin/vim
elif [ -f /usr/bin/vi ]; then
  alias vi=/usr/bin/vim
fi

# --------
# less more
# --------
#export PAGER=lv
export PAGER='less'

export LESS='-R'
# export LESSCHARSET=UTF-8
export LESSCHARSET=
#Source-hilight with less
# export LESSOPEN='| /usr/local/bin/src-hilite-lesspipe.sh %s'
# export LESS='--RAW-CONTROL-CHARS'
# alias more='more -r'
# alias more='more -R'

# ------
# ALIAS
# ------
alias ls='ls -Gh' #--show-control-chars' Mac
# Mac
export LSCOLORS='gxfxcxdxbxegedabagacad'
alias lo='ls -lo'
alias loa='ls -loa'
# alias ls='ls -Fh' #--show-control-chars' linux
alias ll='ls -l'
alias llm='ls -l | more'
alias la='ls -la'
alias lam='ls -la | more'
alias lo='ls -lo'
alias loa='ls -loa'
alias lt='ls -lt'
alias ltr='ls -ltr'
alias ltra='ls -ltra'
alias lraT='ls -lraT'
alias cp='cp -iv'
alias rm='rm -iv'
alias mv='mv -iv'
alias clr=clear
alias lv='lv -Ia -Ou8'
alias soz='source ~/.zsh/.zshrc'
alias soze='source ~/.zshenv'
alias ress="rename -v -X -S ' ' _ -S - '' -S . '' ~/Desktop/スク*.*"
#alias ress="rename -v -X -s スクリーンショット SS -S ' ' _ -S - '' -S . '' スク*.*"

# --------
# find grep
# --------
 alias ggrep='ggrep --color=always '
 alias gegrep='gegrep --color=always '
#alias grep_ca='/usr/bin/grep --color=always '
 alias grep='/usr/bin/grep --color=always '
 alias grep_cn='/usr/bin/grep --color=never '
#alias ag_cn='/usr/local/bin/ag --nocolor '
#  (ex ggrep -r 日本語 */* | less -R
#alias kuuk='ggrep -r 空海 */* | less -R'
alias kuuk=sh\ -c\ \''ggrep --color=always -r "$1" */*.txt | less -R'\'\ -
# NG alias ggrep='ggrep --color=auto '
# NG alias grep='/usr/bin/grep --color=auto '
alias figr='~/bin/figr.sh'
alias fna='~/bin/fna.sh'
# alias fna=sh\ -c\ \''find . -name "$1" -type f -print'\'\ -
# alias figr=sh\ -c\ \''find . -name \*"$1"\* -type f -print0 | xargs -0 grep --color -Hn "$2"'\'\ -

# ------
# atool 圧縮:atool <Archive>.<拡張子> -a <Filename1> <Filename2>
# ------
 alias unat='atool -x '
 alias lsat='atool -l '

# ------
# MACINTOSH
# CD TRAY
# ------
alias tra_close='drutil -drive 1 tray close'
alias tra_eject='drutil eject'
alias tra_open='drutil -drive 1 tray open'


# ------
# MAN
# ------
alias man='LANG=ja_JP.UTF-8 /usr/bin/man'
alias eman='env LANG=C /usr/bin/man'
#alias man='LANG=ja_JP.UTF-8 /usr/local/jman/bin/man'
#alias eman='env LANG=C /opt/local/bin/man'

ShellScriptのダブルクォートとシングルクォートの違い - ぴよぴよ.py

シェルにおけるシングルクォート、ダブルクォート、バッククォートで囲った場合の挙動の違い

シェルのエイリアスで環境変数を使うときはクォーテーションに気をつけよう - Qiita

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?