맞춤형 Linux 서버 초기 설정
알아두면 편한 개발지식

맞춤형 Linux 서버 초기 설정

나만의 LINUX CLI 환경설정

[1단계: o-my-zsh shell 설치]
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

 

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

 

[2단계:테마 바꾸기]
vim ~/.zshrc

THEME="agnoster"

다른 theme : https://github.com/ohmyzsh/ohmyzsh/wiki/Themes

 

[3단계: 폰트 설치]

https://github.com/powerline/fonts

source ~/.zshrc

 

[4단계: brew 설치]

https://www.whatwant.com/entry/LinuxBrew-install-Ubuntu-1804

 

sudo apt-get install build-essential curl file git

 

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

 

vim ~/.zshrc
<주의>

1)무조건 따라 적으면 안되고, 내가 설치한 환경 설정이 이 위치에 있는지 확인 필요.

2)이미 이 환경 변수 썻는지도 체크 꼭 필요!

 

export PATH="/home/yebin/.linuxbrew/bin:$PATH"

export MANPATH="/home/yebin/.linuxbrew/share/man:$MANPATH"

export INFOPATH="/home/yebin/.linuxbrew/share/info:$INFOPATH"

 

source ~/.zshrc

 

brew 확인 작업!

brew install hello

 

[5단계 autojump 설치]
# autojump 설치
brew install autojump

git clone git://github.com/wting/autojump.git

# Run the installation script and follow on screen instructions.
cd autojump
./install.py

 

[6단계 자동완성 설치]
# zsh-autosuggestion 설치
brew install zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

 

[7단계 하이라이팅 설치]:
#설치
brew install zsh-syntax-highlighting
#적용
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

 

~/.zshrc 파일 plugin에 각각 추가!! 

 

[주의]: powerline font가 권한 문제로 안된다면?

1) 폰트 따로 설치

https://github.com/naver/d2codingfont

 

2)폰트 적용

https://mkil.tistory.com/366

 

테마 컬러 바꾸기

https://laziness.xyz/2018/03/ZSH-Installation

 

[8단계 tmux이용하기]:

 

#파일 열고 안에 적은
vim ~/.tmux.conf
#아래 명령어로 적용
tmux source ~/.tmux.conf

 

[tmux 디자인 바꾸기 + 명령어 더 편하게 바꾸기]

 

set-window-option -q -g utf-8 on
set -g default-terminal "xterm"
setw -g mode-keys vi

unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
bind \\ split-window -h
#bind - split-window -v
bind - split-window 
unbind '"'
unbind %
bind r source-file ~/.tmux.conf

bind -n M-h select-pane -L
bind -n M-l select-pane -R
bind -n M-k select-pane -U
bind -n M-j select-pane -D
bind -n M-Left resize-pane -L 25
bind -n M-Right resize-pane -R 25
bind -n M-Up resize-pane -U 5
bind -n M-Down resize-pane -D 5
bind -n M-o select-pane -t :.+
bind -n M-n next-window
bind -n M-p previous-window
bind -n M-c new-window
# set -g mouse on

### DESIGN CHANGES ###
set-option -g visual-activity on
set-option -g visual-bell on
set-option -g visual-silence on
set-window-option -g monitor-activity on
set-option -g bell-action none
setw -g clock-mode-colour colour5
setw -g mode-style fg=colour1,bg=colour32

set -g pane-border-style fg=colour4
set -g pane-active-border-style bg=default,fg=colour9

set -g status-position top
set -g status-justify left
set -g status-bg default
set -g status-fg colour137
set -g status-style dim
set -g status-left '#[fg=colour51,bg=colour0,bold] %R '
set -g status-right '#[fg=colour51,bg=colour0,bold] #(cat /etc/os-release | grep "^ID=" | cut -d\= -f2) '
set -g status-right-length 100

setw -g window-status-current-style bg=colour14,fg=colour00,bold
setw -g window-status-current-format ' #I#[fg=colour0] #[fg=colour0]#W#[fg=colour0] '

setw -g window-status-style fg=colour49,none,bg=colour00
setw -g window-status-format '#I #W '

setw -g window-status-bell-style fg=colour255,bold,bg=colour1

set -g message-style fg=colour232,bold,bg=colour16

setw -g window-status-activity-style none
setw -g window-status-last-style none
setw -g window-status-bell-style none
set -sg escape-time 0

참조: https://github.com/ccss17/dotfiles/blob/master/.tmux.conf

 

[9단계 gotop이용하기]:

https://github.com/cjbassi/gotop

brew tap cjbassi/gotop
brew install gotop

 

[10단계 명령어 단축키 설정]:
#aliases 생성후
vim ~/.zsh_aliases 
#단축키 적고
alias src="source ~/.zshrc"
alias t=tmux
alias v=vim
alias rm=rm -i
alias c=clear
alias cs='cd ..'
alias d=docker
alias bpy=bpython
#alias ls='lsd --icon never'
alias ls='lsd'
alias cl='clear;ls'
alias l='ls'
alias la='ls -a'
alias ll='ls -la'
alias lt='ls --tree'
alias g=git
alias gdb='gdb -q'
alias py=python 
alias py2=python2
alias py3=python3
alias q=exit
alias tldr='tldr -t base16'
#aliases 적용
source ~/.zsh_aliases

 

[11단계 conda 가상환경 설치]:
wget https://repo.anaconda.com/archive/Anaconda3-2021.04-Linux-x86_64.sh
chmod +x Anaconda3-2021.04-Linux-x86_64.sh
./Anaconda3-2021.04-Linux-x86_64.sh
vim ~/.zshrc
#나의 경우 위치는:/home/yebin/anaconda3
export PATH=/usr/anaconda3/bin:$PATH
#가상 환경 확인
conda info --envs
#가상 환경 만들기
conda create --name "가상환경이름" python="파이썬버젼"
#가상 환경 키기
source activate 가상환경 이름

 

[12단계 vim 이용하기]:

명령어: https://joyfulbean.tistory.com/262

더 편하게 이용하기: https://hyoje420.tistory.com/51

[.vimrc 나의 설정]

syntax enable
"set termguicolors
colors onedark
"colors monokai_pro

set switchbuf=usetab
set encoding=utf-8
set foldmethod=syntax
set nofoldenable
set hlsearch
set ignorecase
set softtabstop=4
set shiftwidth=4
autocmd FileType make setlocal noexpandtab
se nu rnu
set smartindent
set tabstop=4
set expandtab

map <silent> <C-c> :IndentLinesToggle<CR>
map <silent> <C-m> :se nu!<CR>:se rnu!<CR>
map <silent> <C-s> :w<CR>
map <silent> <C-q> :q<CR>
map <silent> <C-o> :vsp ~/.vimrc<CR>
nmap <silent> <F10> :tabn<CR>
nmap <silent> <F9> :tabp<CR>
nmap <silent> <C-p> :NERDTreeToggle<CR>
nmap <silent> <Up> :resize -5<CR>
nmap <silent> <Down> :resize +5<CR>
nmap <silent> <Left> :vertical resize -5<CR>
nmap <silent> <Right> :vertical resize +5<CR>
nmap <silent> <Space> :nohlsearch<Bar>:echo<CR>
nmap <silent> <C-k> :wincmd k<CR>
nmap <silent> <C-j> :wincmd j<CR>
nmap <silent> <C-h> :wincmd h<CR>
nmap <silent> <C-l> :wincmd l<CR>

cnoreabbrev install PlugInstall
cnoreabbrev status PlugStatus
cnoreabbrev update PlugUpdate
cnoreabbrev euckr :e ++enc=euc-kr

hi Normal guibg=NONE ctermbg=NONE
hi LineNr guibg=NONE ctermbg=NONE
"hi Comment guifg=#afb0ff ctermfg=LightCyan
set t_Co=256
set cursorline
hi cursorline term=none cterm=none guibg=#303000 ctermbg=234

let g:airline_theme='cool'
"let g:airline_theme='cobalt2'

" indent line settings
let g:indentLine_color_term = 20
let g:indentLine_color_gui = '#A4E57E'
let g:indentLine_color_tty_light = 7 " (default: 4)
let g:indentLine_setConceal = 0

" NERDTree settings
let NERDTreeShowHidden=1

set nocompatible              " be iMproved, required
filetype off                  " required

call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-easy-align'
Plug 'sheerun/vim-polyglot'
Plug 'VundleVim/Vundle.vim'
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'scrooloose/nerdcommenter'
"Plug 'Valloric/YouCompleteMe'
Plug 'terryma/vim-multiple-cursors'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'yggdroot/indentline'
Plug 'dart-lang/dart-vim-plugin'
Plug 'fidian/hexmode'
Plug 'tpope/vim-eunuch'
Plug 'rust-lang/rust.vim'
Plug 'rhysd/vim-clang-format'
call plug#end()

'알아두면 편한 개발지식' 카테고리의 다른 글

CLI 초기 설정  (0) 2021.05.11
Zsh쉘  (0) 2021.05.11
vim  (0) 2021.01.28
SQLlight  (0) 2021.01.28
C++ google style convention 과 CppCoreGuidelines  (0) 2020.08.23