diff --git a/.gitmodules b/.gitmodules index 29b68b9..795adb2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "vim/.vim/autoload"] path = vim/.vim/autoload url = https://github.com/junegunn/vim-plug +[submodule "tmux/.tmux/plugins/tpm"] + path = tmux/.tmux/plugins/tpm + url = https://github.com/tmux-plugins/tpm diff --git a/git/.gitconfig b/git/.gitconfig index 5ba9f4f..9882759 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -4,10 +4,10 @@ [hub] protocol = https [user] - name = Chris Seto - email = chriskseto@gmail.com + name = Fabian von Feilitzsch + email = fabian@fabianism.us [credential] - helper = osxkeychain + helper = cache [alias] st = status co = checkout diff --git a/packages.txt b/packages.txt index 039c489..a1f6242 100644 --- a/packages.txt +++ b/packages.txt @@ -1,4 +1,6 @@ +ruby stow zsh tmux vim +fasd diff --git a/setup.sh b/setup.sh index d06e8c7..c439857 100755 --- a/setup.sh +++ b/setup.sh @@ -1,6 +1,13 @@ +echo "Initializing submodules" git submodule init git submodule update +echo "Linking zsh configuration" stow zsh +echo "Linking vim configuration" stow vim +echo "Linking git configuration" stow git +echo "Linking tmux configuration" stow tmux +echo "Installing tmuxinator" +gem install --user-install tmuxinator diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index c7e6b9b..5ec7c9f 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -15,12 +15,12 @@ set -g default-terminal "screen-256color" # Use vim keybindings setw -g mode-keys vi set -g status-keys vi -setw -g utf8 on +# setw -g utf8 on # use mouse in copy mode -setw -g mode-mouse on +setw -g mouse on # status line -set -g status-utf8 on +# set -g status-utf8 on set -g status-justify left set -g status-bg colour2 set -g status-fg colour0 @@ -29,8 +29,8 @@ set -g status-interval 2 set -g status-left-length 32 set -g status-right-length 150 -set -g pane-border-fg colour255 -set -g pane-active-border-fg colour2 +# set -g pane-border-fg colour255 +# set -g pane-active-border-fg colour2 set -g status-right "#(date +\"%c\")" set -g status-left '#[fg=colour235,bg=colour252,bold] ❐ #S #[fg=colour252,bg=colour238,nobold]⮀#[fg=colour245,bg=colour238,bold] #(hostname -s) #[fg=colour238,bg=colour2,nobold]⮀' @@ -92,20 +92,18 @@ bind + select-layout main-horizontal ############ # Toggle mouse on +unbind m bind m \ - set -g mode-mouse on \;\ - set -g mouse-resize-pane on \;\ - set -g mouse-select-pane on \;\ - set -g mouse-select-window on \;\ - display 'Mouse: ON' - -# Toggle mouse off -bind M \ - set -g mode-mouse off \;\ - set -g mouse-resize-pane off \;\ - set -g mouse-select-pane off \;\ - set -g mouse-select-window off \;\ - display 'Mouse: OFF' + set -g mouse on + # set -g set-clipboard off + # set -g mouse-utf8 on + # set -g select-pane on + # set-option -g -q mouse on \;\ + # bind-key -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M" \;\ + # bind-key -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M" \;\ + # bind-key -t vi-copy WheelUpPane halfpage-up \;\ + # bind-key -t vi-copy WheelDownPane halfpage-down \;\ + # display 'Mouse: ON' # Navigate panes ################ @@ -118,7 +116,7 @@ bind-key v split-window -h -c "#{pane_current_path}" bind-key s split-window -v -c "#{pane_current_path}" # smart pane switching with awareness of vim splits -is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"' +is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"' bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" @@ -158,16 +156,24 @@ bind C-q confirm kill-server bind tab choose-window -# Make copy-n-paste work on OSX -############################### - # Setup 'v' to begin selection as in Vim -bind-key -t vi-copy v begin-selection -bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy" - -# Make vim yanking work with OSX system clipboard -set-option -g default-command "reattach-to-user-namespace -l zsh" +bind-key -T copy-mode-vi v send -X begin-selection +bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' # Remove lag from esc + key -> alt code # IE make neovim usable set -sg escape-time 0 + +# List of plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @plugin 'tmux-plugins/tmux-continuum' + +# Resurrect/Continuum options +set -g @resurrect-capture-pane-contents 'on' +set -g @continuum-boot 'on' +set -g @continuum-restore 'on' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run '~/.tmux/plugins/tpm/tpm' diff --git a/tmux/.tmux/plugins/tpm b/tmux/.tmux/plugins/tpm new file mode 160000 index 0000000..59f7885 --- /dev/null +++ b/tmux/.tmux/plugins/tpm @@ -0,0 +1 @@ +Subproject commit 59f78857f656afd462d7bc99b31cc8cc36c1872c diff --git a/tmux/tmuxinator.zsh b/tmux/tmuxinator.zsh new file mode 100644 index 0000000..4c76c94 --- /dev/null +++ b/tmux/tmuxinator.zsh @@ -0,0 +1,30 @@ +#compdef tmuxinator mux + +_tmuxinator() { + local commands projects + commands=(${(f)"$(tmuxinator commands zsh)"}) + projects=(${(f)"$(tmuxinator completions start)"}) + + if (( CURRENT == 2 )); then + _describe -t commands "tmuxinator subcommands" commands + _describe -t projects "tmuxinator projects" projects + elif (( CURRENT == 3)); then + case $words[2] in + copy|debug|delete|open|start) + _arguments '*:projects:($projects)' + ;; + esac + fi + + return +} + +_tmuxinator + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/vim/.vimrc b/vim/.vimrc index 6d31d56..d9d2cdb 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -2,13 +2,40 @@ set nocompatible " be iMproved " Spacebar is a much better leader than \ or , let mapleader = "\" +set modifiable " Automatically source the vimrc file after saving it autocmd bufwritepost .vimrc source $MYVIMRC """"" PLUGINS """"" call plug#begin() +" Nice note taking plugin +Plug 'xolox/vim-misc' +Plug 'xolox/vim-notes' +:let g:notes_directories = ['~/Documents/Notes'] +:let g:notes_suffix = '.txt' + + +" Window swap +Plug 'wesQ3/vim-windowswap' + +"Puppet +Plug 'rodjek/vim-puppet' + " ESSENTIALS +Plug 'fabianvf/pytest.vim' +nmap tF :Pytest file verbose +nmap tc :Pytest class verbose +nmap tm :Pytest method verbose +nmap tf :Pytest function verbose +nmap tdF :Pytest file verbose doctest +nmap tdc :Pytest class verbose doctest +nmap tdm :Pytest method verbose doctest +nmap tdf :Pytest function verbose doctest + +Plug 'bling/vim-airline' +let g:airline#extensions#hunks#enabled = 0 +Plug 'christoomey/vim-tmux-navigator' Plug 'tpope/vim-sensible' Plug 'rstacruz/vim-opinion' @@ -52,14 +79,16 @@ let g:NERDTreeMouseMode = 3 let g:NERDTreeRespectWildIgnore = 1 let NERDTreeIgnore = ['\.pyc$', '__pycache__'] +Plug 'tpope/vim-obsession' Plug 'scrooloose/syntastic' nnoremap s :SyntasticCheck " NOTE: Don't use syntastic with python; we use khuno for that -let g:syntastic_mode_map = { 'mode': 'active', - \ 'active_filetypes': [], - \ 'passive_filetypes': [ 'html', 'rst', 'md', 'python'] } +" let g:syntastic_mode_map = { 'mode': 'active', +" \ 'active_filetypes': ['ruby'], +" \ 'passive_filetypes': [ 'html', 'rst', 'md', 'python'] } let g:syntastic_python_checkers = ['flake8', 'python'] +let g:syntastic_ruby_checkers = ['rubylint', 'mri'] " let g:syntastic_javascript_checkers = ['jsxhint', 'jshint'] " autocmd! BufEnter *.jsx let b:syntastic_checkers=['jsxhint'] " Disable some features to make syntastic faster @@ -70,16 +99,16 @@ Plug 'alfredodeza/khuno.vim' " NICE TO HAVE -Plug 'bling/vim-airline' -let g:airline_theme='tomorrow' +" Plug 'bling/vim-airline' +" let g:airline_theme='tomorrow' " Show buffers in tabline -let g:airline#extensions#tabline#enabled = 1 +" let g:airline#extensions#tabline#enabled = 1 " Disable stuff I don't need to see -let g:airline#extensions#hunks#enabled = 0 -let g:airline#extensions#bufferline#enabled = 1 -let g:airline#extensions#tagbar#enabled = 0 -let g:airline#extensions#virtualenv#enabled = 0 -let g:airline#extensions#csv#enabled = 0 +" let g:airline#extensions#hunks#enabled = 0 +" let g:airline#extensions#bufferline#enabled = 1 +" let g:airline#extensions#tagbar#enabled = 0 +" let g:airline#extensions#virtualenv#enabled = 0 +" let g:airline#extensions#csv#enabled = 0 Plug 'christoomey/vim-tmux-navigator' Plug 'SirVer/ultisnips' @@ -122,10 +151,10 @@ nnoremap :Scratch:set ft=python Plug 'airblade/vim-gitgutter' " Set gitgutter's bindings manually to avoid clashes let g:gitgutter_map_keys = 0 -nmap gh GitGutterStageHunk -nmap gH GitGutterRevertHunk -nmap [h GitGutterPrevHunk -nmap ]h GitGutterNextHunk +nmap gh (GitGutterStageHunk) +nmap gH (GitGutterRevertHunk) +nmap [h (GitGutterPrevHunk) +nmap ]h (GitGutterNextHunk) Plug 'tpope/vim-fugitive' map gs :Gstatus map gb :Gblame @@ -177,6 +206,38 @@ if executable('npm') " Rename with rr (also like in python-mode) autocmd Filetype javascript noremap r :TernRename endif +Plug 'sophacles/vim-bundle-mako' +Plug 'plasticboy/vim-markdown' +let g:vim_markdown_folding_disabled=1 + +" Idris stuff +Plug 'idris-hackers/idris-vim' + +Plug 'ZoomWin' +Plug 'terryma/vim-multiple-cursors' +" For previewing markdown, rst ,etc +Plug 'greyblake/vim-preview' +Plug 'matchit.zip' +Plug 'duff/vim-scratch' +" Open scratch buffer with space-tab +command! ScratchToggle call ScratchToggle() + +function! ScratchToggle() + if exists("w:is_scratch_window") + unlet w:is_scratch_window + exec "q" + else + exec "normal! :Sscratch\\L" + let w:is_scratch_window = 1 + endif +endfunction + +nnoremap :ScratchToggle + +""" Go configuration +Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' } +let g:go_fmt_command = "goimports" + call plug#end() filetype plugin indent on @@ -188,7 +249,7 @@ set encoding=utf-8 set autoindent set autoread " reload files when changed on disk, i.e. via `git checkout` set backupcopy=yes -set clipboard=unnamed " Make "yanks" work with system clipboard +set clipboard=unnamedplus set wildmenu wildmode=longest,list,full " Indents @@ -198,13 +259,66 @@ set softtabstop=4 " when hitting , pretend like a tab is removed, even if sp set shiftwidth=4 " number of spaces to use for autoindenting set shiftround " use multiple of shiftwidth when indenting with '<' and '>' + " No bells set noerrorbells visualbell t_vb= """ VISUAL SETTINGS """ set t_Co=256 " Must be 256 for many themes to display correctly " Favorites: hybrid iceberg Tomorrow hybrid-light -silent! colorscheme hybrid +silent! colorscheme iceberg +command! TransparencyToggle call TransparencyToggle() + +function! TransparencyToggle() + if exists("w:is_transparent") + unlet w:is_transparent + exec "hi Normal ctermbg=" . w:normal_bg + exec "hi NonText ctermbg=" . w:nontext_bg + exec "hi CursorLine ctermbg=" . w:cursorline_bg + exec "hi CursorLineNr ctermbg=" . w:cursornr_bg + exec "hi LineNr ctermbg=" . w:linenr_bg + exec "hi GitGutterAdd ctermbg=" . w:gitgutteradd_bg + exec "hi GitGutterAdd ctermfg=" . w:gitgutteradd_fg + exec "hi GitGutterChange ctermbg=" . w:gitgutterchange_bg + exec "hi GitGutterChange ctermfg=" . w:gitgutterchange_fg + exec "hi GitGutterDelete ctermbg=" . w:gitgutterdelete_bg + exec "hi GitGutterDelete ctermfg=" . w:gitgutterdelete_fg + + else + let w:normal_bg = synIDattr(synIDtrans(hlID('Normal')), 'bg') + let w:nontext_bg = synIDattr(synIDtrans(hlID('NonText')), 'bg') + let w:cursorline_bg = synIDattr(synIDtrans(hlID('CursorLine')), 'bg') + let w:cursornr_bg = synIDattr(synIDtrans(hlID('CursorLineNr')), 'bg') + let w:linenr_bg = synIDattr(synIDtrans(hlID('LineNr')), 'bg') + let w:gitgutteradd_bg = synIDattr(synIDtrans(hlID('GitGutterAdd')), 'bg') + let w:gitgutteradd_fg = synIDattr(synIDtrans(hlID('GitGutterAdd')), 'fg') + let w:gitgutterchange_bg = synIDattr(synIDtrans(hlID('GitGutterChange')), 'bg') + let w:gitgutterchange_fg = synIDattr(synIDtrans(hlID('GitGutterChange')), 'fg') + let w:gitgutterdelete_bg = synIDattr(synIDtrans(hlID('GitGutterDelete')), 'bg') + let w:gitgutterdelete_fg = synIDattr(synIDtrans(hlID('GitGutterDelete')), 'fg') + + exec "hi Normal ctermbg=none" + exec "hi NonText ctermbg=none" + exec "hi CursorLine ctermbg=none" + exec "hi CursorLineNr ctermbg=none" + exec "hi LineNr ctermbg=none" + exec "hi GitGutterAdd ctermbg=none" + exec "hi GitGutterAdd ctermfg=" . w:gitgutteradd_fg + exec "hi GitGutterChange ctermbg=none" + exec "hi GitGutterChange ctermfg=" . w:gitgutterchange_fg + exec "hi GitGutterDelete ctermbg=none" + exec "hi GitGutterDelete ctermfg=" . w:gitgutterdelete_fg + let w:is_transparent = 1 + endif +endfunction + +nnoremap t :TransparencyToggle +" May want to have different schemes for termvim vs gvim +" if has('gui_running') +" silent! colorscheme emacs +" else +" silent! colorscheme underwater +" endif " Show trailing whitespace set list listchars=tab:▸\ ,trail:▫ @@ -230,7 +344,8 @@ set wildignore+=*.swp,*~,._* set wildignore+=*.pyc,*__pycache__* " Enable basic mouse behavior such as resizing buffers. set mouse=a mousemodel=popup " Right-click pops up a menu -if exists('$TMUX') " Support resizing in tmux + +if exists('$TMUX') && !has('nvim') " Support resizing in tmux set ttymouse=xterm2 endif @@ -288,7 +403,7 @@ set pastetoggle=z " toggle paste mode cnoremap w!! %!sudo tee > /dev/null % " select last pasted text nnoremap gp `[v`] -" Easy syntax switching +" Easy syntax switchin g nnoremap Tp :set ft=python nnoremap Tj :set ft=javascript nnoremap Tr :set ft=rst @@ -352,3 +467,18 @@ if has('gui_running') set go-=L endif endif + +set relativenumber +set number +function! NumberToggle() + if(&relativenumber == 1) + set norelativenumber + set number + echo ':set number' + else + set relativenumber + set number + echo ':set relativenumber' + endif +endfunc +nmap n :call NumberToggle() diff --git a/zsh/.zpreztorc b/zsh/.zpreztorc index 7e5d4af..7d59bdd 100644 --- a/zsh/.zpreztorc +++ b/zsh/.zpreztorc @@ -34,7 +34,6 @@ zstyle ':prezto:load' pmodule \ 'completion' \ 'prompt' \ 'osx' \ - 'git' \ 'python' # diff --git a/zsh/.zshrc b/zsh/.zshrc index 0ea49a8..877689a 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,4 +1,38 @@ #!/usr/bin/env zsh +# shortcut to this dotfiles path is $ZSH +export ZSH=$HOME/.dotfiles +export ANSIBLE_NOCOWS=1 +export PATH=$PATH:~/scripts:~/.cabal/bin:~/bin +export SHELL='/usr/bin/zsh' +export EDITOR='vim' +export OSF=~/code/cos/osf.io +export SCRAPI=~/code/cos/scrapi +export GOPATH=$HOME/go +export PATH=$PATH:$GOPATH/bin +export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python +alias ansalon='telnet ansalonmud.net 8679' + + +# typeset -U fpath +fpath=(~/.zsh/oc $fpath) + +# Disable caps lock +# setxkbmap -option caps:swapescape + +source ~/dotfiles/tmux/tmuxinator.zsh + + +alias g='git' +command -v vimx >/dev/null 2>&1 && alias vim='vimx' +alias gssh='SSH_AUTH_SOCK=~/.gnupg/S.gpg-agent.ssh && ssh' +alias c='clear' +alias mkpasswd='python -c "from passlib.hash import sha512_crypt; import getpass; print sha512_crypt.encrypt(getpass.getpass())"' +# use .localrc for SUPER SECRET CRAP that you don't +# want in your public, versioned repo. +if [[ -a ~/.localrc ]] +then + source ~/.localrc +fi # Source Prezto. if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then @@ -10,8 +44,95 @@ autoload -U compinit compinit # Make autoenv always work -# cd . -# +cd . +# fortune -o -s -n 300 | cowsay -f dragon-and-cow | lolcat + + + +export WORKON_HOME=~/Envs +_virtualenvwrapper_script=$(command -v virtualenvwrapper.sh) +if [[ "$?" = 0 ]]; then + source ${_virtualenvwrapper_script} +fi + +pyclean () { + ZSH_PYCLEAN_PLACES=${*:-'.'} + noglob find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete + noglob find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete +} + +# added by travis gem +[ -f /Users/fabian/.travis/travis.sh ] && source /Users/fabian/.travis/travis.sh + +# Show git branch +setopt prompt_subst +autoload -Uz vcs_info +zstyle ':vcs_info:*' actionformats \ + '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' +zstyle ':vcs_info:*' formats \ + '%F{4}%s%F{3}%F{2}:%F{4}%F{2}%b%F{5}%f ' +zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' + +zstyle ':vcs_info:*' enable git cvs svn + +# or use pre_cmd, see man zshcontrib +vcs_info_wrapper() { + vcs_info + if [ -n "$vcs_info_msg_0_" ]; then + echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del" + fi +} + +venv_info_wrapper() { + if [ -n "$VIRTUAL_ENV" ]; then + local _virtualenv_path + _virtualenv_path=(${(s:/:)VIRTUAL_ENV}) + echo "($_virtualenv_path[-1])" + fi +} + +dir_info_wrapper() { + local _cwd + local _dir + local _path + local _dirs + local _under_home + local _path_pieces + _path_pieces=() + _under_home=false + _cwd="$(pwd)" + + if [[ "$_cwd" =~ ^"$HOME"(/|$) ]]; then + _cwd="~${$(pwd)#$HOME}" + _under_home=true + fi + + _dirs=(${(s:/:)_cwd}) + + for _dir in $_dirs; do + _path_pieces+="$_dir[1]" + done + + _path_pieces[-1]=$_dirs[-1] + + for _piece in $_path_pieces; do + _path+="/$_piece" + done + + if [ "$_path" = "" ]; then + _path='/' + fi + + if [ "$_under_home" = true ]; then + _path[1]="" + fi + + echo "$_path" +} + +PROMPT='$(venv_info_wrapper)%F{6}$(dir_info_wrapper)%f %F{9}❯%F{3}❯%F{2}❯%f ' +RPROMPT=$'$(vcs_info_wrapper)' + function colours() { for i in {0..255} ; do printf "\x1b[38;5;${i}mcolour${i}\n" @@ -25,8 +146,8 @@ export PATH=$PATH:~/.bin # Go Lang things export GOPATH=$HOME/Go export PATH=$PATH:$GOPATH/bin -export GOVERSION=$(brew list go | head -n 1 | cut -d '/' -f 6) -export GOROOT=$(brew --prefix)/Cellar/go/$GOVERSION/libexec +# export GOVERSION=$(brew list go | head -n 1 | cut -d '/' -f 6) +# export GOROOT=$(brew --prefix)/Cellar/go/$GOVERSION/libexec export EDITOR=vim # Screw nano @@ -44,7 +165,7 @@ DISABLE_CORRECTION="true" unsetopt correct unsetopt correct_all -. ~/.bin/z.sh +# . ~/.bin/z.sh alias py="python" alias py3="python3" @@ -69,9 +190,137 @@ function pyclean() { find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete } - setopt no_share_history unsetopt share_history bindkey '^R' history-incremental-search-backward bindkey '^E' end-of-line bindkey '^A' beginning-of-line + +if which ruby >/dev/null && which gem >/dev/null; then + PATH="$(ruby -rrubygems -e 'puts Gem.user_dir')/bin:$PATH" +fi + +export VAGRANT_DEFAULT_PROVIDER=libvirt +unset GREP_OPTIONS +alias npm-exec='PATH=$(npm bin):$PATH' +alias go-exec='PATH=$GOPATH/bin:$PATH' + +setopt clobber +alias rhciag='ag -l --silent --ignore fusor/fusor-ember-cli --ignore fusor/ui --ignore \*.po' +alias keep-trying='while [ $? -ne 0 ] ; do sleep 2 && bash -c "$(fc -ln -1)" ; done' +alias try-forever='while [ true ] ; do sleep 2 && bash -c "$(fc -ln -1)" ; done' +alias please='sudo bash -c "$(fc -ln -1)"' +alias yum='sudo dnf' +alias sssh='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' +alias sscp='scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' + +function kill-spotify { + local _processes=$(ps aux | grep com.spotify.Client | grep -v grep | awk '{print $2}') + while read -r _process; do + if [[ ! -z "${_process}" ]]; then + echo "Killing Spotify process (pid ${_process})" + while ((kill ${_process}) > /dev/null 2>&1); do + echo "Waiting for pid ${_process} to die..." + sleep 1 + done + fi + done <<< "${_processes}" +} + +function start-spotify { + local _processes=$(ps aux | grep com.spotify.Client | grep -v grep | awk '{print $2}') + if [[ ! -z "${_processes}" ]]; then + echo "Spotify is already running" + else + echo "Starting Spotify" + flatpak run com.spotify.Client > /var/log/spotify-script.log 2>&1 + fi +} + +function spotify { + local state=${1:-online} + local _proxy_pid="$(ps aux | grep 'ssh -f -N -D 0.0.0.0:1080 localhost' | grep -v grep | awk '{print $2}')" + case "${state}" in + "online") + if [[ -z "${_proxy_pid}" ]]; then + echo "Starting local socks proxy for Spotify" + ssh -f -N -D 0.0.0.0:1080 localhost + kill-spotify + fi + start-spotify + ;; + "offline") + if [[ ! -z "${_proxy_pid}" ]]; then + echo "Killing local socks proxy for Spotify running on pid ${_proxy_pid}" + kill ${_proxy_pid} + fi + start-spotify + ;; + "stop") + if [[ ! -z "${_proxy_pid}" ]]; then + echo "Killing local socks proxy for Spotify running on pid ${_proxy_pid}" + kill ${_proxy_pid} + fi + kill-spotify + ;; + "--help") + echo "USAGE: spotify online|offline|stop" + ;; + esac +} + +function make_nfs_share { + _path="/nfs_data/$1" + if [ -d "$_path" ] + then + echo "$_path already exists" + grep -q -e "$_path \*(rw)" /etc/exports || (echo "$_path *(rw)" | sudo tee -a /etc/exports) + # skip + else + sudo mkdir -p $_path + sudo chmod -R +755 $_path + sudo chown -R 36:36 $_path + grep -q -e "$_path \*(rw)" /etc/exports || (echo "$_path *(rw)" | sudo tee -a /etc/exports) + echo "$_path share created" + fi + sudo exportfs -ra +} + +if [[ -s "$(command -v activate.sh)" ]]; then + source $(which activate.sh) +fi + +# added by travis gem +[ -f /home/fabian/.travis/travis.sh ] && source /home/fabian/.travis/travis.sh + +export NVM_DIR="/home/fabian/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm + +# FASD configuration +eval "$(fasd --init auto)" +# Aliases: +alias a='fasd -a' # any +alias s='fasd -si' # show / search / select +alias d='fasd -d' # directory +alias f='fasd -f' # file +alias sd='fasd -sid' # interactive directory selection +alias sf='fasd -sif' # interactive file selection +alias z='fasd_cd -d' # cd, same functionality as j in autojump +alias j='fasd_cd -d' # cd, same functionality as j in autojump +alias zz='fasd_cd -d -i' # cd with interactive selection +alias v='f -t -e vim -b viminfo' # open file most recently edited in vim +alias vv='f -i -t -e vim' # open file in vim +alias todo='todo -G' +export GOBIN=/home/fabian/Go/bin +export GOROOT=/usr/local/go +export PATH=$PATH:$GOROOT/bin + +if [[ -s "$(command -v oc)" ]]; then + source <(oc completion zsh) +fi + +alias pbcopy='xclip -selection clipboard' +function kubesecret { + secret_name="${1}" + kubectl get secret ${secret_name} -o go-template='{{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}' +}