Last active
July 29, 2019 16:57
-
-
Save sim2github/8af35612abf509dc91d805dd0e857515 to your computer and use it in GitHub Desktop.
$HOME zsh configs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.commonrc.zsh | |
# Vi mode | |
bindkey -v | |
# Use vim cli mode | |
bindkey '^P' up-history | |
bindkey '^N' down-history | |
# backspace and ^h working even after | |
# returning from command mode | |
bindkey '^?' backward-delete-char | |
bindkey '^h' backward-delete-char | |
# ctrl-w removed word backwards | |
bindkey '^w' backward-kill-word | |
# ctrl-r starts searching history backward | |
bindkey '^r' history-incremental-search-backward | |
#function zle-line-init zle-keymap-select { | |
# VIM_PROMPT="%{$fg_bold[yellow]%} [% NORMAL]% %{$reset_color%}" | |
# RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/} $EPS1" | |
# zle reset-prompt | |
#} | |
#zle -N zle-line-init | |
#zle -N zle-keymap-select | |
export KEYTIMEOUT=1 | |
alias cp='cp -iv' # Preferred 'cp' implementation | |
alias mv='mv -iv' # Preferred 'mv' implementation | |
alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation | |
alias ll='ls -FGlAhp' # Preferred 'ls' implementation | |
alias less='less -FSRXc' | |
alias du='du -sh' | |
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside | |
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less' | |
alias sdm='sudo shutdown -h now' | |
alias h='history' | |
alias hg='history | grep' | |
alias ag='alias | grep' | |
alias dirarch='find . -maxdepth 1 -type d ! -name . -exec tar -zcvf '{}'.tar.gz '{}'/ \; -exec rm -rf '{}' \;' | |
#autoload -U zmv | |
alias vz='vim $HOME/.zshrc' | |
alias vzu='source ~/.zshrc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.dockerrc.zsh | |
# Docker | |
alias ds='bash --login "/Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/start.sh"' | |
#alias ds='bash --login "$HOME/docker_start.sh"' | |
alias dp='nmap 192.168.99.101' | |
alias d='docker' | |
alias dm='docker-machine' | |
alias dc='docker-compose' | |
alias dcr='docker-compose run' | |
alias dcu='docker-compose up -d' | |
alias dce='docker-compose exec' | |
alias dcd='docker-compose down' | |
alias dst='docker stop $(docker ps -a -q)' | |
alias drm='docker rm $(docker ps -a -q)' | |
alias drmi='docker rmi $(docker images -q)' | |
alias dps='docker ps -a --format "table {{.Names}}\t{{.Command}}\t{{.Ports}}\t{{.Image}}"' | |
alias di='docker images' | |
alias dr='docker run' | |
alias drit='docker run -it --rm' | |
alias drd='docker run -d --rm' | |
alias de='docker exec -it' | |
alias dl='docker logs' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.macosrc.zsh | |
alias vi='vim' | |
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder | |
function pfd() { | |
osascript 2>/dev/null <<EOF | |
tell application "Finder" | |
return POSIX path of (target of window 1 as alias) | |
end tell | |
EOF | |
} | |
function pfs() { | |
osascript 2>/dev/null <<EOF | |
set output to "" | |
tell application "Finder" to set the_selection to selection | |
set item_count to count the_selection | |
repeat with item_index from 1 to count the_selection | |
if item_index is less than item_count then set the_delimiter to "\n" | |
if item_index is item_count then set the_delimiter to "" | |
set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter | |
end repeat | |
EOF | |
} | |
function cdf() { | |
cd "$(pfd)" | |
} | |
function pushdf() { | |
pushd "$(pfd)" | |
} | |
ql () { qlmanage -p "$*" >& /dev/null; } # ql: Opens any file in MacOS Quicklook Preview | |
function quick-look() { | |
(( $# > 0 )) && qlmanage -p $* &>/dev/null & | |
} | |
function man-preview() { | |
man -t "$@" | open -f -a Preview | |
} | |
compdef _man man-preview | |
function qa { | |
osascript <<EOF | |
tell application "$*" to quit | |
EOF | |
} | |
alias cce='diskutil mount disk0s1 && vim /Volumes/EFI/EFI/CLOVER/config.plist' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.tmux.conf | |
# Set the default input delay to improve Vim performance | |
set -sg escape-time 1 | |
# tell tmux to use 256 colour terminal | |
set -g default-terminal "screen-256color" | |
# KEYS | |
set -g mode-keys vi | |
set -g status-keys vi | |
# Reload .tmux.conf with "r" | |
bind r source-file ~/.tmux.conf \; display "Reloaded!" | |
# Select panes with vi-style movements | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
set-option -g history-limit 10000 | |
setw -g mouse on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ~/.vimrc | |
" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim | |
" vim +PluginInstall +qall | |
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'VundleVim/Vundle.vim' | |
Plugin 'scrooloose/syntastic' | |
Plugin 'vim-airline/vim-airline' | |
Plugin 'kien/ctrlp.vim' | |
Plugin 'elzr/vim-json' | |
Plugin 'tpope/vim-fugitive' | |
Plugin 'tpope/vim-surround' | |
Plugin 'mattn/emmet-vim' | |
Plugin 'fatih/vim-go' | |
Plugin 'fatih/molokai' | |
Plugin 'AndrewRadev/splitjoin.vim' | |
Plugin 'SirVer/ultisnips' | |
Plugin 'leafgarland/typescript-vim' | |
Plugin 'terryma/vim-multiple-cursors' | |
Plugin 'Chiel92/vim-autoformat' | |
" " All of your Plugins must be added before the following line | |
call vundle#end() " required | |
filetype plugin indent on | |
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
" Plugins Settings | |
let g:user_emmet_mode='a' | |
let g:airline#extensions#tabline#enabled = 1 | |
imap <expr> <tab> emmet#expandAbbrIntelligent("\<tab>") | |
let g:slime_target = "tmux" | |
let g:rbpt_colorpairs = [ | |
\ ['magenta', 'purple1'], | |
\ ['cyan', 'magenta1'], | |
\ ['green', 'slateblue1'], | |
\ ['yellow', 'cyan1'], | |
\ ['red' , 'springgreen1'], | |
\ ['magenta', 'green1'], | |
\ ['cyan', 'greenyellow'], | |
\ ['green', 'yellow1'], | |
\ ['yellow', 'orange1'], | |
\ ] | |
let g:rbpt_max = 16 | |
" Colorscheme | |
syntax enable | |
set t_Co=256 | |
let g:rehash256 = 1 | |
let g:molokai_original = 1 | |
colorscheme molokai | |
set ttyfast " Indicate fast terminal conn for faster redraw | |
set ttymouse=xterm2 " Indicate terminal type for mouse codes | |
set ttyscroll=3 " Speedup scrolling | |
set laststatus=2 " Show status line always | |
set encoding=utf-8 " Set default encoding to UTF-8 | |
set autoread " Automatically read changed files | |
set autoindent " Enabile Autoindent | |
set backspace=indent,eol,start " Makes backspace key more powerful. | |
set incsearch " Shows the match while typing | |
set hlsearch " Highlight found searches | |
set noerrorbells " No beeps | |
set number " Show line numbers | |
set showcmd " Show me what I'm typing | |
set noswapfile " Don't use swapfile | |
set nobackup " Don't create annoying backup files | |
set splitright " Vertical windows should be split to right | |
set splitbelow " Horizontal windows should split to bottom | |
set autowrite " Automatically save before :next, :make etc. | |
set hidden " Buffer should still exist if window is closed | |
set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats | |
set noshowmatch " Do not show matching brackets by flickering | |
set noshowmode " We show the mode with airline or lightline | |
set ignorecase " Search case insensitive... | |
set smartcase " ... but not it begins with upper case | |
set completeopt=menu,menuone " Show popup menu, even if there is one entry | |
set pumheight=10 " Completion window max size | |
set nocursorcolumn " Do not highlight column (speeds up highlighting) | |
set nocursorline " Do not highlight cursor (speeds up highlighting) | |
set lazyredraw " Wait to redraw | |
"""""""""""""""""""""" | |
" Mappings " | |
"""""""""""""""""""""" | |
" Set leader shortcut to a comma ','. By default it's the backslash | |
let mapleader = "," | |
" Jump to next error with Ctrl-n and previous error with Ctrl-m. Close the | |
" quickfix window with <leader>a | |
map <C-n> :cnext<CR> | |
map <C-m> :cprevious<CR> | |
nnoremap <leader>a :cclose<CR> | |
" Visual linewise up and down by default (and use gj gk to go quicker) | |
noremap <Up> gk | |
noremap <Down> gj | |
noremap j gj | |
noremap k gk | |
" Search mappings: These will make it so that going to the next one in a | |
" search will center on the line it's found in. | |
nnoremap n nzzzv | |
nnoremap N Nzzzv | |
" Act like D and C | |
nnoremap Y y$ | |
" Enter automatically into the files directory | |
autocmd BufEnter * silent! lcd %:p:h | |
""""""""""""""""""""" | |
" Plugins " | |
""""""""""""""""""""" | |
" vim-go | |
let g:go_fmt_command = "goimports" | |
let g:go_autodetect_gopath = 1 | |
let g:go_list_type = "quickfix" | |
let g:go_highlight_types = 1 | |
let g:go_highlight_fields = 1 | |
let g:go_highlight_functions = 1 | |
let g:go_highlight_methods = 1 | |
let g:go_highlight_extra_types = 1 | |
let g:go_highlight_generate_tags = 1 | |
" Open :GoDeclsDir with ctrl-g | |
nmap <C-g> :GoDeclsDir<cr> | |
imap <C-g> <esc>:<C-u>GoDeclsDir<cr> | |
augroup go | |
autocmd! | |
" Show by default 4 spaces for a tab | |
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 | |
" :GoBuild and :GoTestCompile | |
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR> | |
" :GoTest | |
autocmd FileType go nmap <leader>t <Plug>(go-test) | |
" :GoRun | |
autocmd FileType go nmap <leader>r <Plug>(go-run) | |
" :GoDoc | |
autocmd FileType go nmap <Leader>d <Plug>(go-doc) | |
" :GoCoverageToggle | |
autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle) | |
" :GoInfo | |
autocmd FileType go nmap <Leader>i <Plug>(go-info) | |
" :GoMetaLinter | |
autocmd FileType go nmap <Leader>l <Plug>(go-metalinter) | |
" :GoDef but opens in a vertical split | |
autocmd FileType go nmap <Leader>v <Plug>(go-def-vertical) | |
" :GoDef but opens in a horizontal split | |
autocmd FileType go nmap <Leader>s <Plug>(go-def-split) | |
" :GoAlternate commands :A, :AV, :AS and :AT | |
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit') | |
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit') | |
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split') | |
autocmd Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe') | |
augroup END | |
" build_go_files is a custom function that builds or compiles the test file. | |
" It calls :GoBuild if its a Go file, or :GoTestCompile if it's a test file | |
function! s:build_go_files() | |
let l:file = expand('%') | |
if l:file =~# '^\f\+_test\.go$' | |
call go#test#Test(0, 1) | |
elseif l:file =~# '^\f\+\.go$' | |
call go#cmd#Build(0) | |
endif | |
endfunction | |
"-----------------------------------------------------------" | |
if has("autocmd") | |
autocmd BufWritePost .vimrc source $MYVIMRC | |
autocmd BufReadPost fugitive://* set bufhidden=delete | |
endif | |
" Autoformat | |
au BufWrite * :Autoformat | |
noremap <F3> :Autoformat<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment