Skip to content

Commit

Permalink
ADD: linux setup automation
Browse files Browse the repository at this point in the history
  • Loading branch information
Iovesophy committed Jul 28, 2024
1 parent 7c00c1f commit 3b9bb83
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 40 deletions.
31 changes: 14 additions & 17 deletions macos/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
EMAIL:[email protected]

all: ansible setup
NAME:=dotfiles

.PHONY: setup
setup: test
./setup.sh $(EMAIL)

.PHONY: test
test: install
shellcheck ./tools/install_ansible.sh
shellcheck ./setup.sh
zsh -n zshrc
vint vimrc
setup:
./setup.sh $(EMAIL) $(NAME)
-./tools/install_brew.sh
sudo update-alternatives --config editor

.PHONY: install
install:
for i in --syntax-check --list-tasks --check -v ; do \
ansible-playbook -i inventory/localhost.ini install_playbook.yml $$i; done

.PHONY: ansible
ansible:
./tools/install_ansible.sh
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

9 changes: 8 additions & 1 deletion macos/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ if [ -z "${1:-""}" ]; then
fi

cp gitconfig_addon ~/.gitconfig
git config --global user.name "$(whoami)"
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

Expand Down
9 changes: 9 additions & 0 deletions macos/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
15 changes: 0 additions & 15 deletions macos/vimrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
"vim-plug Start. https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
" ruby https://vimawesome.com/plugin/vim-ruby
Plug 'vim-ruby/vim-ruby'
" python https://vimawesome.com/plugin/python-mode
Plug 'klen/python-mode'
" C#
Plug 'OmniSharp/omnisharp-vim'
" markdown
Plug 'plasticboy/vim-markdown'
Plug 'kannokanno/previm'
Plug 'tyru/open-browser.vim'
Plug 'lambdalisue/gina.vim'
call plug#end()
" vim-plug Fin.
" esc
noremap <C-f> <esc>
noremap! <C-f> <esc>
Expand Down
28 changes: 21 additions & 7 deletions macos/zshrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
alias python="/usr/bin/python3"
source /usr/local/opt/zsh-git-prompt/zshrc.sh
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 %F{cyan}%c%F{black}$(git_super_status)%F{green}]%f'
PS1='%F{green}[%n cicd/agent01 %F{cyan}%c%F{white}$(__git_ps1)%F{green}]>>%f'

autoload -Uz compinit
rm -f ~/.zcompdump
Expand All @@ -14,20 +23,25 @@ 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
alias history="history 0"

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

export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')
# brew
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

0 comments on commit 3b9bb83

Please sign in to comment.