LoginSignup
3
3

More than 5 years have passed since last update.

zsh/bashのカスタマイズ

Last updated at Posted at 2016-03-16

zsh

zshをデフォルトで使用

~/.zshrc
LANG=ja_JP.UTF-8

# 最新のディレクトリのみ表示
PS1="%1~ %(!.#.$) "

# ヒストリの設定
HISTFILE=~/.zsh_history
HISTSIZE=1000000
SAVEHIST=1000000

# cd した先のディレクトリをディレクトリスタック(履歴)に追加する
# `cd +<Tab>` でディレクトリの履歴(新しい順)が表示され、そこに移動できる
setopt AUTO_PUSHD

"~/.zshrc" 50L, 1110C

DIRSTACKSIZE=100

autoload -Uz compinit && compinit

zstyle ':completion:*' menu select
zstyle ':completion:*:cd:*' ignore-parents parent pwd
# zstyle ':completion:*:descriptions' format '%BCompleting%b %U%d%u'

# エイリアス設定
alias ls='ls -F'
alias la='ls -a'
alias ll='ls -l'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias mkdir='mkdir -p'

# ディレクトリ移動
alias ..='cd ../'
alias ...='cd ../..'
alias ....='cd ../../..'

# 関数
# 差分表示
function diff(){
        git diff $1 --name-only
}

# 差分のみでzipをつくる
function zip(){
        git diff $1 --name-only | xargs -I {} zip $1.zip {} -x .DS_Store
}

bash

~/.bash_profile
export PATH="$PATH:$HOME/bin"

if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi
~/.bashrc
LANG=ja_JP.UTF-8
PS1='\W \$ '
export LESS='--no-init'

set -o ignoreeof

# コマンド履歴設定
shopt -s histappend
HISTSIZE=1000000
HISTFILESIZE=1000000

※ 例えばaliasに登録したlsを一時的に無効に(本来のlsを実行)する場合はcommand ls もしくは \ls

参考
新しいLinuxの教科書

3
3
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
3
3