Setting / Terminal

codelab·2023년 10월 5일
0

Dev

목록 보기
5/9

주의! mac 터미널이라면 아래 두 부분이 다릅니다.


git clone https://github.com/chriskempson/base16-shell.git ~/.config/base16-shell

brew install coreutils


# .zshrc
# Base16 Shell
BASE16_SHELL="$HOME/.config/base16-shell/"
source "$BASE16_SHELL/profile_helper.sh"


# gdircolors를 사용하여 LS_COLORS 환경 변수를 설정합니다.
if type gdircolors > /dev/null 2>&1; then
    eval "$(gdircolors -b)"
fi

# 명령에 색상을 추가합니다.
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

eval "$(gdircolors ~/.dircolors)"

Vim 색 & 라인번호 추가

vi ~/.vimrc

syntax on
colorscheme default 
set number

Install zsh


# _setup 디렉토리 생성
mkdir -pv $HOME/_setup && cd $HOME/_setup


#### 다시 설치하는 경우: 아래 3줄 주석 해제 ####
# bash

# rm -rf ~/Repos ~/.zshrc ~/.cache ~/.zsh ~/.config ~/_setup
# sudo apt remove -y zsh


# 패키지 관리자(ubuntu: apt, centos: yum 등)를 최신으로 업데이트하고 
# zsh, highlight, git를 설치힙니다.
sudo apt update -y && sudo apt install -y zsh highlight git curl

# 비번을 설정합니다.
sudo passwd $USER

# 기본 shell을 zsh로 변경합니다.
chsh -s /bin/zsh

# zsh을 실행하고 2번을 선택합니다.
zsh  # 2

# 디렉토리 목록 색상을 다운로드합니다.
curl -L https://raw.githubusercontent.com/nordtheme/dircolors/develop/src/dir_colors -o ~/.dircolors

# zsh 디렉토리를 생성하고 플러그인을 다운받습니다.
cat << EOT > zsh_install.sh
mkdir -pv $HOME/Repos
git clone --depth 1 https://github.com/marlonrichert/zsh-snap.git $HOME/Repos/znap && source $HOME/Repos/znap/znap.zsh 
git clone --depth 1 https://github.com/junegunn/fzf.git $HOME/Repos/fzf && $HOME/Repos/fzf/install --all
git clone --depth 1 https://github.com/spaceship-prompt/spaceship-prompt.git $HOME/Repos/spaceship-prompt
git clone https://github.com/chriskempson/base16-shell.git $HOME/Repos/base16-shell
git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git $HOME/Repos/fast-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions $HOME/Repos/zsh-autosuggestions
EOT

# shell file에 실행권한을 부여하고 실행합니다. 
chmod +x ./zsh_install.sh && ./zsh_install.sh

.zshrc 세팅

# GITHUB_TOKEN: GITHUB 로그인 > Settings > Developer Settings > Personal access tokens > 둘 중 아무거나 발급합니다.
# cluserctl init 을 할 때 web hook을 이용하는데 토큰이 없으면 다운로드 횟수 제한으로 1시간 기다려야 합니다.
export GITHUB_TOKEN=<GITHUB_TOKEN>

cat << EOT > $HOME/.zshrc
[ -f "$HOME/Repos/fzf/.fzf.zsh" ] && source "$HOME/Repos/fzf/.fzf.zsh"
[ -f $HOME/.fzf.zsh ] && source $HOME/.fzf.zsh

# Base16 Shell
[ -n '$PS1' ] && \
    [ -s "$HOME/Repos/base16-shell/profile_helper.sh" ] && \
        source "$HOME/Repos/base16-shell/profile_helper.sh"
        
base16_google-dark



# dircolors
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

alias catc="highlight $1 --out-format xterm256 -l --force -s solarized-light --no-trailing-nl"
alias caty="highlight $1 --out-format xterm256 -l --force -s solarized-light --no-trailing-nl --syntax=yaml"


#  Zsh History 
# History won't save duplicates.
setopt HIST_IGNORE_ALL_DUPS
# History won't show duplicates on search.
setopt HIST_FIND_NO_DUPS


#  Zsh Theme 
source $HOME/Repos/spaceship-prompt/spaceship.zsh-theme
SPACESHIP_PROMPT_ORDER=(
    user
    dir
    host
    git
    exec_time
    line_sep
    jobs
    exit_code
    char
)
SPACESHIP_USER_SHOW=always
SPACESHIP_PROMPT_ADD_NEWLINE=false
SPACESHIP_CHAR_SYMBOL=">"
SPACESHIP_CHAR_SUFFIX=" "


#  Zsh Plugins 
# fast-syntax-highlighting
source $HOME/Repos/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
# zsh-autosuggestions
source $HOME/Repos/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh


#  Znap 
[ -f $HOME/Repos/znap/znap.zsh ] ||
    git clone --depth 1 https://github.com/marlonrichert/zsh-snap.git $HOME/Repos/znap

source $HOME/Repos/znap/znap.zsh 

znap prompt sindresorhus/pure
znap source marlonrichert/zsh-autocomplete
znap eval iterm2 'curl -fsSL https://iterm2.com/shell_integration/zsh'
znap function _pyenv pyenv "znap eval pyenv 'pyenv init - --no-rehash'"
compctl -K    _pyenv pyenv
znap install aureliojargas/clitest zsh-users/zsh-completions


# aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'


#  Kubernetes 
# To load completions for each session, execute once:
kubectl completion zsh > "$HOME/Repos/zsh-users/zsh-completions/src/_kubectl"
clusterctl completion zsh > "$HOME/Repos/zsh-users/zsh-completions/src/_clusterctl"
autoload -U compinit; compinit
alias k=kubectl
alias c=clusterctl
export KUBECONFIG=$HOME/.kube/config
# export KUBECONFIG=/etc/kubernetes/admin.conf


#  Setting env 
# github api token
export GITHUB_TOKEN=$GITHUB_TOKEN
export CLUSTER_TOPOLOGY=true

# oci
export OCI_CLI_AUTH=instance_principal
export USE_INSTANCE_PRINCIPAL=true
export USE_INSTANCE_PRINCIPAL_B64=$(echo -n true | base64)

#  Setting PATH 
EOT

# zsh 설정파일(.zshrc)을 리로드합니다.
source ~/.zshrc
profile
Think about a better architecture

0개의 댓글