Verified Commit 75af89d9 authored by jisuchoi's avatar jisuchoi 💻
Browse files


+ Add dropped .git-template/* files
+ Change color code on gitconfig
+ Fix glow installation script
+ Add keybase installation
+ Fix absolute path on gitconfig:git-template-dir
+ Change git ignore to include git-template under file
alias gpgs='gpg --list-key --with-subkey'
alias e='emacs -nw --no-splash'
# ~/.bash_logout
# ~/.bash_profile
. /etc/os-release
unset distro_pkgmgr
unset cmds
declare -A distro_pkgmgr
declare -A cmds
pkgmgr=([arch]='pacman' [ubuntu]='apt')
install=([arch]='-Syu' [ubuntu]='install -y')
check=([arch]='-Q' [ubuntu]='-qq list')
pkgmgr_install="sudo `echo ${pkgmgr[$ID]} ${install[$ID]}`"
pkgmgr_check="`echo ${pkgmgr[$ID]} ${check[$ID]}`"
cmds=( \
[git]="git=${pkgmgr_install} git" \
[gpg]="gnupg=${pkgmgr_install} gnupg" \
[scrot]="scrot=${pkgmgr_install} scrot" \
[xclip]="xclip=${pkgmgr_install} xclip" \
[glow]="glow=echo 'deb [trusted=yes] /' |
sudo tee /etc/apt/sources.list.d/charm.list;
sudo apt update && sudo apt-get -y install glow" \
[keybase]="keybase=curl --remote-name;sudo apt install ./keybase_amd64.deb" \
function set_packages()
for cmd in "${!cmds[@]}"; do
if [ -z "$($pkgmgr_check $cmd)" ]; then
# pkgname=${record%%=*}
#echo $pkgname
#echo $install_cmd
eval $install_cmd
echo $cmd command exist.
function set_git()
if [ -z "$($pkgmgr_check $cmd)" ]; then
return 1;
export GIT_PS1_SHOWUPSTREAM="verbose name"
export GIT_PS1_DESCRIBE_STYLE="branch"
if [ -f '/usr/share/git/completion/git-completion.bash' ]; then
source /usr/share/git/completion/git-completion.bash
source /usr/share/git/completion/
function set_gpg()
if [ -f "~/.gnupg/public_jisu.pgp" ];then
gpg --import ~/.gnupg/public_jisu.pgp
gpg --auto-key-locate $1 --locate-keys $2
if [ -f "~/.gnupg/private_jisu.pgp" ];then
gpg --import ~/.gnupg/private_jisu.pgp
git config --global user.signKey `gpg --list-key | awk 'FNR == 4 {gsub(/ /,"");print}'`
function myclip()
scrot -s -q 100 foo.png;
xclip -selection c -t image/png < foo.png ;
rm foo.png;
function myhelp()
echo "myclip, set_gpg, set_git, set_packages available"
echo "If you use keybase pgp, you don't need to 'set_gpg' command"
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QR_IM_MODULE=ibus
export LANG=ko_KR.UTF-8
# set bell-style none
[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases
[[ -f ~/.bashrc ]] && . ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
# Console Style Constants
RST="\[\e[0m\]" # Reset Styles
BOLD="\[\e[1m\]" # Bold
UL="\[\e[4m\]" # Underline
HIGHLIGHT="\[\e[7m\]" # Highlight (inverse)
FG_BLACK="\[\e[90m\]" # Foreground black
FG_RED="\[\e[91m\]" # Foreground red
FG_GREEN="\[\e[92m\]" # Foreground green
FG_YELLOW="\[\e[93m\]" # Foreground yellow
FG_BLUE="\[\e[94m\]" # Foreground blue
FG_MAGENTA="\[\e[95m\]" # Foreground magenta
FG_CYAN="\[\e[96m\]" # Foreground cyan
FG_WHITE="\[\e[97m\]" # Foreground white
BG_BLACK="\[\e[100m\]" # Background black
BG_RED="\[\e[101m\]" # Background red
BG_GREEN="\[\e[102m\]" # Background green
BG_YELLOW="\[\e[103m\]" # Background yellow
BG_BLUE="\[\e[104m\]" # Background blue
BG_MAGENTA="\[\e[105m\]" # Background magenta
BG_CYAN="\[\e[106m\]" # Background cyan
BG_WHITE="\[\e[107m\]" # Background white
if [ "$color_prompt" = yes ]; then
TIME="\n${FG_MAGENTA}[\d \t]${RST}"
TERM127="`if [ \$? != 0 ]; then echo '${FG_RED}${BOLD}${HIGHLIGHT}!${RST}'; fi`"
CWD="${FG_YELLOW}[job]: \j [dir]: \w${RST}${debian_chroot:+($debian_chroot)}"
PS1="${TIME} ${TERM127} ${CWD} ${GIT} \n${HOST} "
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
# enable color support of ls and also add handy aliases
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'
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
. /usr/share/git/completion/
. /usr/share/git/completion/git-completion.bash
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
;; Basic Setting ;;
; Remove menu bar at top
(menu-bar-mode 0)
; Kill default buffer
;; Makes *scratch* empty.
(setq initial-scratch-message "")
;; Removes *scratch* from buffer after the mode has been set.
(defun remove-scratch-buffer ()
(if (get-buffer "*scratch*")
(kill-buffer "*scratch*")))
(add-hook 'after-change-major-mode-hook 'remove-scratch-buffer)
;; Removes *messages* from the buffer.
(setq-default message-log-max nil)
(kill-buffer "*Messages*")
;; Removes *Completions* from buffer after you've opened a file.
(add-hook 'minibuffer-exit-hook
'(lambda ()
(let ((buffer "*Completions*"))
(and (get-buffer buffer)
(kill-buffer buffer)))))
;; Don't show *Buffer list* when opening multiple files at the same time.
(setq inhibit-startup-buffer-menu t)
;; Show only one active window when opening multiple files at the same time.
(add-hook 'window-setup-hook 'delete-other-windows)
; Line Wrap mode on for all buffers
(global-visual-line-mode t)
; Line Number
(global-linum-mode t)
(setq linum-format "%4d \u2502 ")
; Column Number
(setq column-number-mode t)
; Save last cursor position
(require 'saveplace)
(setq-default save-place t)
(save-place-mode t)
; Match braket and braces
(show-paren-mode t)
(setq show-paren-delay 0)
;Tab width
(setq-default tab-width 4)
(setq-default tab-stop-list 4)
; C coding style
(setq c-default-style "bsd")
(setq c-default-style "bsd" c-basic-offset 4)
; Time Display
;; Basic mode ;;
(cua-mode t)
(blink-cursor-mode t)
(electric-layout-mode t)
(electric-indent-local-mode t)
(add-to-list 'auto-mode-alist '("\\.c\\'" . c-mode))
(add-to-list 'auto-mode-alist '("\\.cpp\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.el\\'" . lisp-mode))
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(semantic-mode t)
;The idle scheduler with automatically reparse buffers in idle time.
(global-semantic-idle-scheduler-mode t)
(global-semantic-idle-completions-mode t)
(global-semantic-idle-summary-mode t)
(add-to-list 'semantic-default-submodes 'global-semantic-stickyfunc-mode t)
(add-to-list 'semantic-default-submodes 'global-semantic-highlight-func-mode t)
(global-set-key [f12] 'describe-key)
(global-set-key [f10] 'describe-function)
(global-set-key [f1] 'shell)
(global-set-key [f3] 'execute-extended-command)
;; Basic Shortcut Keys ;;
; find word
(define-key isearch-mode-map [(control f)] 'isearch-repeat-forward)
(global-set-key (kbd "C-f") 'isearch-forward)
(define-key isearch-mode-map (kbd "C-f") 'isearch-repeat-forward)
(define-key isearch-mode-map (kbd "C-d") 'isearch-repeat-backward)
; arrow key
(global-set-key (kbd "M-i") 'previous-line)
(global-set-key (kbd "M-k") 'next-line)
(global-set-key (kbd "M-j") 'left-char)
(global-set-key (kbd "M-l") 'right-char)
; buffer arrow key
(global-set-key (kbd "C-x C-j") 'previous-buffer)
(global-set-key (kbd "C-x C-l") 'next-buffer)
; window key
(global-set-key (kbd "M-9") 'split-window-vertically)
(global-set-key (kbd "M-0") 'split-window-horizontally)
(global-set-key (kbd "M-p") 'delete-window)
(global-set-key (kbd "M-_") 'shrink-window-horizontally)
(global-set-key (kbd "M-+") 'enlarge-window-horizontally)
(global-set-key (kbd "M--") 'shrink-window)
(global-set-key (kbd "M-=") 'enlarge-window)
(global-set-key (kbd "C-c C-j") 'windmove-left)
(global-set-key (kbd "C-c C-l") 'windmove-right)
(global-set-key (kbd "C-c C-i") 'windmove-up)
(global-set-key (kbd "C-c C-k") 'windmove-down)
(global-set-key (kbd "C-l") 'goto-line)
(global-set-key (kbd "C-s") 'save-buffer)
(global-set-key (kbd "C-d") 'backward-delete-char-untabify)
(global-set-key (kbd "TAB") 'self-insert-command)
(global-set-key "\M-q" 'beginning-of-line-text)
(global-set-key "\M-e" 'end-of-line)
;; (global-set-key "\M-x" (lambda () (interactive) (scroll-up 4)))
;; (global-set-key "\M-z" (lambda () (interactive) (scroll-down 4)))
(defun sfp-page-down ()
(- (window-text-height)
(defun sfp-page-up ()
(- (window-text-height)
(global-set-key [next] 'sfp-page-down)
(global-set-key [prior] 'sfp-page-up)
;; Mode keymap setting
; unbind mark set key
(global-unset-key (kbd "C-SPC"))
(global-unset-key (kbd "C-@"))
; unbind python shell send to file key
(add-hook 'python-mode-hook
(local-unset-key (kbd "C-c C-j"))
(local-unset-key (kbd "C-c C-l"))
(local-unset-key (kbd "C-c C-i"))
(local-unset-key (kbd "C-c C-k"))
; input method : set default input method as hangul
(set-input-method "korean-hangul")
; backup files
; put autosave files (ie #foo#) and backup files (ie foo~) in ./.emacs_backup_src/".
(setq backup-directory-alist '(("" . "./.emacs_backup_src/")))
(setq delete-by-moving-to-trash t
version-control t)
; load themek
(load-theme 'wombat)
(require 'package)
(setq package-enable-at-startup t)
(add-to-list 'package-archives '("melpa" . "") t)
(add-to-list 'package-archives '("melpa" . "") t)
;;; 커스텀 모듈 로드 ;;;
;(setq custom-file "~/.emacs.d/custom.el")
;(load custom-file)
;;; 자동 완성 ;;;
;; python 자동 완성 기능 추가
(if (package-installed-p 'auto-virtualenv)
(require 'auto-virtualenv)
(add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
(add-hook 'projectile-after-switch-project-hook 'auto-virtualenv-set-virtualenv)
(add-hook 'python-mode-hook 'anaconda-eldoc-mode)
(autoload 'jedi:setup "jedi" nil t)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)
;; C++
;auto-complete c/c++ 헤더 자동 완성 포함 내용
(defun my:ac-c-headers-init ()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers)
(setq achead:include-directories
(append '("/usr/include"
(setq c-basic-offset 4)
(require 'auto-complete)
(with-eval-after-load 'auto-complete (ac-flyspell-workaround))
;; auto complet config
(if (package-installed-p 'auto-complete-config)
(require 'auto-complete-config)
(global-auto-complete-mode t)
(setq ac-disable-faces nil) ; quotation 안에도 자동 완성되게 해줌. 헤더 자동완성할 때 필요.
(add-hook 'c++-mode-hook 'my:ac-c-headers-init)
(add-hook 'c-mode-hook 'my:ac-c-headers-init)
;; sematic
(semantic-mode t)
(setq semanticdb-default-save-directory "~/.emacs.d/#semanticdb.cache#")
(semantic-add-system-include "/usr/include/" 'c++-mode)
(semantic-add-system-include "/usr/include/" 'c-mode)
(semantic-add-system-include "/usr/global/include" 'c++-mode)
(semantic-add-system-include "/usr/global/include" 'c-mode)
(global-ede-mode 1) ; Enable the Project management system
(global-semantic-idle-scheduler-mode t) ;The idle scheduler with automatically reparse buffers in idle time.
(global-semantic-idle-completions-mode t) ;Display a tooltip with a list of possible completions near the cursor.
(add-to-list 'semantic-default-submodes 'global-semantic-stickyfunc-mode t)
(add-to-list 'semantic-default-submodes 'global-semantic-highlight-func-mode 1)(global-semantic-idle-summary-mode t)
;; (global-set-key [(control tab)] 'semantic-ia-complete-symbol-menu)
(defun my:add-semantic-to-autocomplete()
(add-to-list 'ac-sources 'ac-source-semantic)
(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)
;; 처음 부터 . -> :: 기능을 사용하시려면 아래 "nil" 을 "t" 바꾸세요.
;; (defvar semantic-complete-self-insert-p t)
;; (defun semantic-complete-self-insert-toggle-switch ()
;; (interactive)
;; (if semantic-complete-self-insert-p
;; (progn (setq semantic-complete-self-insert-p nil)
;; (message "semantic-complete-self-insert off") )
;; (progn (setq semantic-complete-self-insert-p t)
;; (message "semantic-complete-self-insert on") ) ) )
;; (defun semantic-complete-self-insert-for-dot-operator (arg)
;; (interactive "p")
;; (if semantic-complete-self-insert-p
;; (call-interactively 'semantic-complete-self-insert)
;; (self-insert-command arg) ) )
;; (defun semantic-complete-self-insert-for-arrow-operator (arg)
;; (interactive "p")
;; (if (and semantic-complete-self-insert-p
;; (string= "-" (char-to-string (char-before (point)) ) ) )
;; (call-interactively 'semantic-complete-self-insert)
;; (self-insert-command arg) ) )
;; (defun semantic-complete-self-insert-for-scope-operator (arg)
;; (interactive "p")
;; (if (and semantic-complete-self-insert-p
;; (string= ":" (char-to-string (char-before (point)) ) ) )
;; (call-interactively 'semantic-complete-self-insert)
;; (self-insert-command arg) ) )
;; (defun c++-mode-additional-semantic-keys ()
;; "Key bindings to add to `c++-mode'."
;; (define-key c++-mode-map [(control c)(control .)] 'semantic-complete-self-insert-toggle-switch)
;; (define-key c++-mode-map "." 'semantic-complete-self-insert-for-dot-operator)
;; (define-key c++-mode-map ">" 'semantic-complete-self-insert-for-arrow-operator)
;; (define-key c++-mode-map ":" 'semantic-complete-self-insert-for-scope-operator)
;; )
;; (add-hook 'c++-mode-hook 'c++-mode-additional-semantic-keys)
;; irony-mode, company-irony
(if (package-installed-p 'company-quickhelp)
(eval-after-load 'company '(add-to-list 'company-backends 'company-irony))
(add-hook 'after-init-hook 'global-company-mode)
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
(add-hook 'c-mode-common-hook (lambda () (global-set-key (kbd "<C-tab>") 'company-complete)))
(add-hook 'c++-mode-hook (lambda () (global-set-key (kbd "<C-tab>") 'company-complete)))
;;; 편의성 설정 ;;;
(global-visual-line-mode 1)
;; move cursor by camelCase
(subword-mode 1)
;;copy & paste, undo redo 일반키(C-c, C-v, C-z, C-shift-z)사용
(cua-mode t)
;; remember cursor position
(if (version< emacs-version "25.0")
(require 'saveplace)
(setq-default save-place t))
(save-place-mode 1))
;; 대괄호 매칭
(show-paren-mode t)
(setq show-paren-delay 0)
;; 디스플레이 하단에 시간 표시
;; linum 모드 켜기
(global-linum-mode t)
(setq linum-format "%4d \u2502 ")
;; 탭 넓이
(setq-default tab-width 4)
;; not use tab instead space
(setq-default indent-tabs-mode nil)
;; c코딩 스타일 지정(글로벌)
(setq c-default-style "bsd" c-basic-offset 4)
(setq c-defun-tactic "go-outward")
;; iedit :전부 바꾸기
(define-key global-map (kbd "C-h C-k") `iedit-mode)
;;; Shortcut ;;;
(global-set-key [f5] 'compile)
(global-set-key [f1] 'manual-entry)
(global-set-key (kbd "C-a") 'mark-whole-buffer)
(global-set-key (kbd "C-w") 'goto-line)
(global-set-key (kbd "C-s") 'save-buffer)
;; arrow key
(global-set-key (kbd "M-i") 'previous-line) ; 【Alt+3】
(global-set-key (kbd "M-k") 'next-line)
(global-set-key (kbd "M-j") 'left-char)
(global-set-key (kbd "M-l") 'right-char) ;
;; buffer arrow key
(global-set-key (kbd "C-x C-j") 'previous-buffer) ; 【Alt+3】
(global-set-key (kbd "C-x C-l") 'next-buffer)
;; auto complete dropdown arrow key
(with-eval-after-load 'company
(define-key company-active-map (kbd "M-i") 'company-select-previous)
(define-key company-active-map (kbd "M-k") 'company-select-next))
;; window control
(global-set-key (kbd "M-*") 'delete-other-windows) ; 【Alt+3】
(global-set-key (kbd "M-(") 'split-window-vertically)
(global-set-key (kbd "M-)") 'split-window-horizontally)
(global-set-key (kbd "<M-RET>") 'other-window) ; 【Alt+Return】 move cursor to next pane
(global-set-key (kbd "M-p") 'delete-window) ; remove current pane
(global-set-key (kbd "M-_") 'shrink-window-horizontally)
(global-set-key (kbd "M-+") 'enlarge-window-horizontally)
(global-set-key (kbd "M--") 'shrink-window)
(global-set-key (kbd "M-=") 'enlarge-window)
;; after copy Ctrl+c in Linux X11, you can paste by `yank' in emacs
(setq gui-select-enable-clipboard t)
(setq x-select-enable-clipboard t)
;; after mouse selection in X11, you can paste by `yank' in emacs
(setq gui-select-enable-primary t)
(setq x-select-enable-primary t)
(setq save-interprogram-paste-before-kill t)
;; search keyword
(global-set-key (kbd "C-f") 'isearch-forward)
(define-key isearch-mode-map (kbd "C-f") 'isearch-repeat-forward)
(define-key isearch-mode-map (kbd "C-d") 'isearch-repeat-backward)
;;; custom face set
;(load-theme 'cyberpunk)