-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bashrc
123 lines (105 loc) · 3.23 KB
/
.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# define message
RED="\e[31;1m"
GREEN="\e[32;1m"
YELLOW="\e[33;1m"
BLUE="\e[34;1m"
CYAN="\e[36;1m"
RESET="\e[0m"
SUCCESS="${GREEN}[SUCCESS]${RESET}"
FAILED="${RED}[FAILED ]${RESET}"
LOG="${CYAN}[LOG ]${RESET}"
# COLOR definitions
DEFAULT=$'%{^[[m%}'$
RED=$'%{^[[1;31m%}'$
GREEN=$'%{^[[1;32m%}'$
YELLOW=$'%{^[[1;33m%}'$
BLUE=$'%{^[[1;34m%}'$
PURPLE=$'%{^[[1;35m%}'$
LIGHT_BLUE=$'%{^[[1;36m%}'$
WHITE=$'%{^[[1;37m%}'$
# set $OS
if [ "$(uname)" = 'Darwin' ]; then
OS='Mac'
elif [ "$(expr substr $(uname -s) 1 5)" = 'Linux' ]; then
OS='Linux'
elif [ "$(expr substr $(uname -s) 1 10)" = 'MINGW32_NT' ]; then
OS='Cygwin'
else
echo -e "${LOG}Your platform ($(uname -a)) is not supported."
exit 1
fi
# install zplug if it has not been installed
test -d "$HOME"/.zplug || curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
# zplug
if [ $OS = 'Linux' ]; then
test $(stat $HOME/.zplug -c '%u') -eq $(id -u) || sudo chown -R $(whoami) $HOME/.zplug
elif [ $OS = 'Mac' ]; then
test $(stat -f '%u' $HOME/.zplug) -eq $(id -u) || sudo chown -R $(whoami) $HOME/.zplug
if [ $(uname -m) = 'x86_64' ]; then
test $(stat -f '%u' /usr/local/share/zsh) -eq $(id -u) || sudo chown -LR $(whoami) /usr/local/share/
fi
fi
# install dein.vim if it has not been installed
test -e "$HOME"/.cache/dein || sh "$HOME"/dotfiles/vim/install_dein.sh
# PATH
export PATH="$PATH:/usr/local/opt/libpcap/bin"
export PATH="$PATH:/usr/local/sbin"
export PATH="$PATH:/usr/local/opt/gnu-getopt/bin"
# pyenv
export PYENV_ROOT="${HOME}/.pyenv"
export PATH="${PYENV_ROOT}/bin:$PATH"
eval "$(pyenv init -)"
# nvm
if [ $OS = 'Linux' ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
elif [ $OS = 'Mac' ]; then
export NVM_DIR="$HOME/.nvm"
source "$(brew --prefix nvm)"/nvm.sh
fi
# for user scripts
export PATH="$PATH:$HOME/bin"
test -d $HOME/bin || mkdir $HOME/bin
# Environmental Variable
export LANG=en_US.UTF-8
export LC_ALL=$LANG
export EDITOR=vim
export PYTHONIOENCODING=utf-8
export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'
# history file
HISTFILE=$HOME/.zsh_history
HISTSIZE=1000000
SAVEHIST=1000000
# PROMPT
if [[ -n "$SSH_CONNECTION" ]];then
ISSSH="%F{cyan}[SSH]%f"
fi
set_prompt() {
local venv=""
if [[ -n "$VIRTUAL_ENV" ]]; then
venv="(%{$fg[cyan]%}$(basename $VIRTUAL_ENV)%{$reset_color%})"
fi
if [ $? = 0 ]; then
PROMPT="${venv}%{$ISSSH$fg[green]%}[%n@%m]%{${reset_color}%} %~"$'\n'"%(!.#.$) "
else
PROMPT="${venv}%{$ISSSH$fg[red]%}[%n@%m]%{${reset_color}%} %~"$'\n'"%(!.#.$) "
fi
}
precmd() {
set_prompt
}
# Aliases
[ -f ~/dotfiles/.aliases.sh ] && source ~/dotfiles/.aliases.sh
stty stop undef # fwd-i-searchが使えるようにsttyのCTRL+Sを無効化
function gcc2(){
FILENAME=$(basename $1);
CFILE=$(basename $1 .c);
#gcc -o $CFILE.out -lm -ansi -pedantic -Wall $FILENAME;
gcc -o "$CFILE" -lm -Wall "$FILENAME";
}
if [ "$OS" = 'Mac' ]; then
# Use 1Password ssh-agent
export SSH_AUTH_SOCK=~/Library/Group\ Containers/2BUA8C4S2C.com.1password/t/agent.sock
fi
cat "$HOME"/dotfiles/asciiart_skyline.txt