Skip to content

Commit

Permalink
ADD: separate linux dotfiles configure
Browse files Browse the repository at this point in the history
  • Loading branch information
Iovesophy committed Jul 28, 2024
1 parent 3b9bb83 commit b46cf3d
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 0 deletions.
21 changes: 21 additions & 0 deletions linux/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
EMAIL:[email protected]
NAME:=dotfiles

.PHONY: setup
setup:
./setup.sh $(EMAIL) $(NAME)
-./tools/install_brew.sh
sudo update-alternatives --config editor

.PHONY: install
install:
sudo apt install -y vim
curl -fsSL https://get.docker.com -o get-docker.sh
./get-docker.sh
sudo groupadd docker
sudo usermod -aG docker $(USER)
sudo chown $(USER):$(USER) /home/$(USER)/.docker -R
mkdir -p /home/$(USER)/.docker
sudo chmod g+rwx $(HOME)/.docker -R
brew install peco

12 changes: 12 additions & 0 deletions linux/gitconfig_addon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[alias]
lg = log --graph --date=short --format='%C(yellow)%h%C(reset)%C(magenta) [%ad]%C(reset)%C(auto)%d%C(reset) %s%C(cyan) @%an%C(reset)'
st = status
cm = commit -m
sh = show -b
df = diff -b
sa = "!git show -b --reverse `git log --format='%h' --merges -n 1`.."
ra = "!git rebase -i `git log --format='%h' --merges -n 1`"
[core]
quotepath = false
[init]
defaultBranch = main
23 changes: 23 additions & 0 deletions linux/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh -eux

if [ -z "${1:-""}" ]; then
exit 1
fi

cp gitconfig_addon ~/.gitconfig
git config --global user.name "$2"
git config --global user.email "$1"

mkdir -p ~/.zsh
cd ~/.zsh
curl -o git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
curl -o git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
curl -o _git https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh
cd -

ln -fs "$(pwd)"/zshrc ~/.zshrc
ln -fs "$(pwd)"/vimrc ~/.vimrc

mkdir -p ~/.config/nvim/
touch ~/.config/nvim/init.vim
ln -fs "$(pwd)"/vimrc ~/.config/nvim/init.vim
9 changes: 9 additions & 0 deletions linux/tools/install_brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -eux

sudo apt-get install build-essential procps curl file git
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.zshrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
sudo apt-get install build-essential
brew install gcc
54 changes: 54 additions & 0 deletions linux/vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
" esc
noremap <C-f> <esc>
noremap! <C-f> <esc>
" init.vim quick setting
nnoremap <Space>.
\ :<C-u>edit $MYVIMRC<CR>
" init.vim quick setting
" env settings
set shiftwidth=4
set tabstop=4
set expandtab
set clipboard+=unnamed " clipboard enable
set fenc=utf-8
set nobackup
set noswapfile
set autoread
set hidden
set showcmd
set number
set cursorline
set cursorcolumn
set virtualedit=onemore
set smartindent
set visualbell
set showmatch
set laststatus=2
set wildmode=list:longest
set title
set nofoldenable
set encoding=utf-8
set fileencodings=utf-8,iso-2022-jp,euc-jp,sjis
set fileformats=unix,dos,mac
nnoremap j gj
nnoremap k gk
syntax enable
nmap <Esc><Esc> :nohlsearch<CR><Esc>
" env settings
" kannokanno/previm
augroup previm_loading
autocmd!
autocmd BufRead,BufNewFile *.md set filetype=markdown
augroup END
let g:previm_open_cmd = 'open -a Google\ Chrome'
nnoremap <silent> <C-p> :PrevimOpen<CR>
" tyru/open-browser.vim
let g:netrw_nogx = 1 " disable netrw's gx mapping.
nmap gx <Plug>(openbrowser-smart-search)
vmap gx <Plug>(openbrowser-smart-search)
" for cloudformation yaml tab space
set expandtab smarttab
augroup yaml-tab
autocmd!
autocmd BufRead,BufNewFile *.yml,*.yaml setlocal tabstop=2 shiftwidth=2 softtabstop=2
augroup end
47 changes: 47 additions & 0 deletions linux/zshrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
source ~/.zsh/git-prompt.sh

fpath=(~/.zsh $fpath)
zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
autoload -Uz compinit && compinit

GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUPSTREAM=auto

setopt PROMPT_SUBST
PS1='%F{green}[%n cicd/agent01 %F{cyan}%c%F{white}$(__git_ps1)%F{green}]>>%f'

autoload -Uz compinit
rm -f ~/.zcompdump
compinit

zstyle ':completion:*:default' list-colors ${(s.:.)LSCOLORS}
zstyle ':completion:*:default' menu select=1

alias ls='ls -GF'
export CLICOLOR=1
export LSCOLORS=gxfxcxdxbxegedabagacad

export HISTFILE=${HOME}/.zsh_history
export HISTSIZE=1000
export SAVEHIST=100000
setopt EXTENDED_HISTORY

setopt auto_cd
setopt share_history
setopt hist_ignore_dups
setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt hist_reduce_blanks

function peco-select-history() {
BUFFER=$(\history -n 1 | tac | peco)
CURSOR=$#BUFFER
zle clear-screen
}
zle -N peco-select-history
bindkey '^r' peco-select-history

# brew
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

0 comments on commit b46cf3d

Please sign in to comment.