Skip to content

Instantly share code, notes, and snippets.

@nekonenene
Last active October 12, 2015 20:12
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 nekonenene/32b73b8a630288ae5a5f to your computer and use it in GitHub Desktop.
Save nekonenene/32b73b8a630288ae5a5f to your computer and use it in GitHub Desktop.
.bahrc For Mac
## .inputrc に書く。補完で大文字小文字を無視
## set completion-ignore-case on
alias s='sudo'
alias ex='exit'
alias cd..='cd ..'
## Mac は open コマンドを多用する
## 参照 : http://staku.designbits.jp/terminal-run-app/
## より詳しく : http://www.absolute-keitarou.net/blog/?p=661
alias emacs='open -a Emacs.app'
alias firefox='open -a Firefox.app'
alias chrome='open -a "Google Chrome.app"'
alias safari='open -a Safari.app'
alias opera='open -a Opera.app'
alias em='emacs'
alias vi='vim'
alias py='python'
alias g='git'
alias cdhome='cd ~/'
alias cdc='cd /'
alias cddoc='cd ~/Document'
alias cddown='cd ~/Download'
alias cdplug='cd ~/Plugin'
alias cdEmacs='cd ~/.emacs.d'
alias gitHatonekoe='git config --global user.name "ハトネコエ"'
alias hatonekoe='gitHatonekoe'
alias nekonenene='gitHatonekoe'
## ####################################################################
## @ コマンド
# エイリアス定義をリセット
## unalias -a
# builtin
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
# coreutils
alias ll='ls -l --time-style=long-iso --color=auto'
alias la='ls -l -g -G --time-style=long-iso --color=auto'
alias l='ls -1 --color=auto'
alias ls='ls -a --color=auto'
alias cp='cp -i -p'
alias mv='mv -i'
alias rm='rm -i'
# grep
alias grep='env -u LC_CTYPE grep --color=always'
alias zgrep='env -u LC_CTYPE zgrep --color=always'
export GREP_COLOR='01;41'
# diffutils
alias sdiff='sdiff -l'
alias pdiff='diff -aurN'
# tree
alias tree='tree -NF'
alias ftree='tree -afipugsDf'
# global
alias gtags='gtags -v'
alias htags='htags -vsF'
# wget
alias wget='wget --trust-server-names --timeout=60'
## ####################################################################
## @ 環境設定
# エディタ
export EDITOR
EDITOR='emacs'
# ページャー
export PAGER
PAGER='less'
# 新規ファイルの権限を設定
umask 022
## ####################################################################
## @ コマンド履歴
# 履歴ファイルの最大履歴数
export HISTFILESIZE
HISTFILESIZE='10240'
# 実行中プロセスの最大履歴数
export HISTSIZE
HISTSIZE='10240'
# 連続した重複履歴を排除
export HISTCONTROL
HISTCONTROL='ignoredups'
# 1~3文字のコマンドと exitを履歴記録対象から除外
export HISTIGNORE
HISTIGNORE='?:??:???:exit'
# 複数行コマンドのコマンド履歴を追加
shopt -s cmdhist
# 編集バッファにコマンド履歴を読み込み
shopt -s histverify
shopt -s histreedit
# コマンド履歴の追記モードを無効化
shopt -u histappend
# 複数端末間でコマンド履歴を共有
export PROMPT_COMMAND
PROMPT_COMMAND="history -a; history -c; history -r"
# コマンドプロンプト
export PS1 PS2
PS1="\$(
retv=\$?
#### fg=\$(test \$retv -eq 0 && echo \"\[\e[0m\e[0;32m\]\" || echo \"\[\e[0m\e[0;33m\]\")
fg=\$(test \$retv -eq 0 && echo \"\[\e[0m\e[1;32m\]\" || echo \"\[\e[0m\e[1;32m\]\")
bg=\$(test \$retv -eq 0 && echo \"\[\e[0;32;42m\]\" || echo \"\[\e[0;33;43m\]\")
#### 一行目(ユーザ名・時間など)をコメントアウト
#### echo -e \" \$bg#\$fg Host: \H | Time: \D{%Y-%m-%d %H:%M:%S} | User: \u | Retv: \$retv\[\e[0m\]\"
#### echo -e \" \$bg#\$fg Path: \w\[\e[0m\]\"
#### echo -e \" \$bg#\$fg Path: \w\[\e[0m\]\"
echo -e \" \$bg#\$fg Path: \w | Time: \D{%H:%M:%S} | \u@\s | Retv: \$retv\[\e[0m\]\n> \"
## PS2='echo -e \" \$bg#\$fg > \"'
)"
## ####################################################################
## @ ユーザ関数
# クリップボード上のパスにディレクトリ移動
function ccd {
local dir="$(cat /dev/clipboard)"
if [[ -d "$dir" ]] ; then
builtin cd "$dir"
else
builtin cd /desktop
fi
}
# ANISカラーコード表示
function ansi_color {
for a in 3 4 ; do
for b in 0 1 2 4 7 ; do
for n in ${a}0 ${a}1 ${a}2 ${a}3 ${a}4 ${a}5 ${a}6 ${a}7 ; do
echo -en "\e[${b};${n}m"
echo -n "\e[${b};${n}m"
echo -ne "\e[0m"
echo -n " "
done
echo
done
echo
done
}
# コマンド未検出時の制御
function command_not_found_handle {
echo "$SHELL: $1: command not found"
return 127
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment