From 684e15a0b31b5f0d48bf6f73d59f9a7b8ef9af6b Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Tue, 24 May 2022 23:48:16 -0700 Subject: [PATCH] Add zsh, nvim, git configs --- git/.config/git/config | 8 ++ nvim/.config/nvim/commands.vim | 11 ++ nvim/.config/nvim/init.vim | 65 ++++++++++ nvim/.config/nvim/keybindings.vim | 17 +++ nvim/.config/nvim/pager.vim | 24 ++++ nvim/.config/nvim/plugins.vim | 118 +++++++++++++++++ nvim/.config/nvim/search.vim | 13 ++ nvim/.config/nvim/spell/en.utf-8.add | 8 ++ nvim/.config/nvim/spell/en.utf-8.add.spl | Bin 0 -> 201 bytes zsh/.config/zsh/.zprofile | 9 ++ zsh/.config/zsh/.zshenv | 32 +++++ zsh/.config/zsh/.zshrc | 65 ++++++++++ zsh/.config/zsh/conf.d/00-aliases.zsh | 151 ++++++++++++++++++++++ zsh/.config/zsh/conf.d/00-keybindings.zsh | 4 + zsh/.config/zsh/conf.d/completion.zsh | 27 ++++ zsh/.config/zsh/conf.d/fzf.zsh | 10 ++ zsh/.config/zsh/conf.d/kp.zsh | 14 ++ zsh/.config/zsh/conf.d/options | 14 ++ zsh/.config/zsh/conf.d/path.zsh | 4 + zsh/.config/zsh/conf.d/prompt.zsh | 35 +++++ zsh/.config/zsh/conf.d/sudo.zsh | 23 ++++ zsh/.config/zsh/conf.d/tmux.zsh | 13 ++ 22 files changed, 665 insertions(+) create mode 100644 git/.config/git/config create mode 100644 nvim/.config/nvim/commands.vim create mode 100644 nvim/.config/nvim/init.vim create mode 100644 nvim/.config/nvim/keybindings.vim create mode 100644 nvim/.config/nvim/pager.vim create mode 100644 nvim/.config/nvim/plugins.vim create mode 100644 nvim/.config/nvim/search.vim create mode 100644 nvim/.config/nvim/spell/en.utf-8.add create mode 100644 nvim/.config/nvim/spell/en.utf-8.add.spl create mode 100755 zsh/.config/zsh/.zprofile create mode 100755 zsh/.config/zsh/.zshenv create mode 100755 zsh/.config/zsh/.zshrc create mode 100644 zsh/.config/zsh/conf.d/00-aliases.zsh create mode 100644 zsh/.config/zsh/conf.d/00-keybindings.zsh create mode 100644 zsh/.config/zsh/conf.d/completion.zsh create mode 100644 zsh/.config/zsh/conf.d/fzf.zsh create mode 100644 zsh/.config/zsh/conf.d/kp.zsh create mode 100644 zsh/.config/zsh/conf.d/options create mode 100644 zsh/.config/zsh/conf.d/path.zsh create mode 100644 zsh/.config/zsh/conf.d/prompt.zsh create mode 100644 zsh/.config/zsh/conf.d/sudo.zsh create mode 100644 zsh/.config/zsh/conf.d/tmux.zsh diff --git a/git/.config/git/config b/git/.config/git/config new file mode 100644 index 0000000..018a1c3 --- /dev/null +++ b/git/.config/git/config @@ -0,0 +1,8 @@ +# This is Git's per-user configuration file. +[user] +name = Eric Torres +email = erictorres4@protonmail.com +[core] + pager = nvim -R +[color] + pager = no diff --git a/nvim/.config/nvim/commands.vim b/nvim/.config/nvim/commands.vim new file mode 100644 index 0000000..9a26264 --- /dev/null +++ b/nvim/.config/nvim/commands.vim @@ -0,0 +1,11 @@ +" Ctags +" ^] goes to the tag +command MakeTags !ctags -R . + +" Show commands +set showcmd + +" Use ripgrep for grepping +set grepprg=rg\ --vimgrep + +" vim: ft=vim diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim new file mode 100644 index 0000000..093eb44 --- /dev/null +++ b/nvim/.config/nvim/init.vim @@ -0,0 +1,65 @@ +" Source other files +source ~/.config/nvim/plugins.vim +source ~/.config/nvim/keybindings.vim +source ~/.config/nvim/commands.vim +source ~/.config/nvim/search.vim + +" Source vim plugins +set rtp+=/usr/share/vim/vimfiles + +" Allow buffers to go to background without needing to write to disk +set hidden + +" Disables vi compatibility +set nocompatible + +" Colors +set termguicolors +"set background=light +"colorscheme breezy + +" Set tabs to 4 spaces +set expandtab +set tabstop=4 +set shiftwidth=4 + +" Set syntax highlighting +syntax enable + +" Set filetype detection +if has ("autocmd") + filetype on + filetype plugin on + filetype indent on +endif + +" Set line numbers +set number + +" Set clipboard to X clipboard buffer +set clipboard+=unnamedplus + +" Indentation +set autoindent +set cindent + +" Disables cursor-shape termcodes +" Stops the weird q from appearing when changing modes +set guicursor= + + +" Window Management +map j_ +map k_ +nmap :wincmd k +nmap :wincmd j +nmap :wincmd h +nmap :wincmd l +set wmh=0 + +" ---------- File finding ---------- +" Provide tab completion +set path+=** + +" Show all options when tab completing +set wildmenu diff --git a/nvim/.config/nvim/keybindings.vim b/nvim/.config/nvim/keybindings.vim new file mode 100644 index 0000000..6cecf27 --- /dev/null +++ b/nvim/.config/nvim/keybindings.vim @@ -0,0 +1,17 @@ +" Disable ex mode +map Q + +" Buffer Management +"nnoremap :buffers:buffer + +" No arrows +map +map +map +map + +" Spelling +inoremap :set spell!a +nnoremap :set spell! + +" vim: ft=vim diff --git a/nvim/.config/nvim/pager.vim b/nvim/.config/nvim/pager.vim new file mode 100644 index 0000000..89863ce --- /dev/null +++ b/nvim/.config/nvim/pager.vim @@ -0,0 +1,24 @@ +" Status line +set laststatus=0 +set cmdheight=1 +set nomodifiable " Only in version 6.0 +set readonly + +" My xterms have a navy-blue background, so I need this line too. +set background=dark + +" Turn syntax on +syntax enable + +" No menu bar and tool bar +set guioptions=aiMr + +" Key bindings. +nmap b +nmap q :q! +nmap +nmap + +" To type the following line, type *two* C-V's followed by two spaces. This +" is how you map the spacebar. +nmap ^V diff --git a/nvim/.config/nvim/plugins.vim b/nvim/.config/nvim/plugins.vim new file mode 100644 index 0000000..7498df8 --- /dev/null +++ b/nvim/.config/nvim/plugins.vim @@ -0,0 +1,118 @@ +" vim-plug +call plug#begin('~/.local/share/nvim/plugins') +Plug 'christoomey/vim-tmux-navigator' +Plug 'dense-analysis/ale' +"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } +"Plug 'tweekmonster/deoplete-clang2' +Plug 'sbdchd/neoformat' +Plug 'junegunn/fzf.vim', { 'do': { -> fzf#install() } } +"Plug 'vim-airline/vim-airline' +"Plug 'vim-airline/vim-airline-themes' + +call plug#end() + +" Configuration for plugins +" ---------- Airline ---------- +let g:airline#extensions#tabline#enabled = 2 +let g:airline#extensions#tabline#fnamemod = ':t' +let g:airline#extensions#tabline#left_sep = ' ' +let g:airline#extensions#tabline#left_alt_sep = '|' +let g:airline#extensions#tabline#right_sep = ' ' +let g:airline#extensions#tabline#right_alt_sep = '|' +let g:airline_left_sep = ' ' +let g:airline_left_alt_sep = '|' +let g:airline_right_sep = ' ' +let g:airline_right_alt_sep = '|' +let g:airline_theme='simple' + +" --------- Ale ---------- +let g:ale_linters = { + \ 'python': ['pylint'], + \ 'vim': ['vint'], + \ 'cpp': ['clang'], + \ 'c': ['clang'] +\} + +" ---------- Deoplete ---------- +let g:deoplete#enable_at_startup = 1 + +" ---------- Deoplete-Clang ---------- +"g:deoplete#sources#clang#libclang_path = "/Library/Developer/CommandLineTools/usr/lib/libclang.dylib" +"g:deoplete#sources#clang#clang_header = "/Library/Developer/CommandLineTools/usr/lib/clang" + +" ---------- Fzf ---------- +map :FZF + +" Setup for brew-installed fzf +set rtp+=/usr/local/opt/fzf + +" Navigate to a tag +function! s:tags_sink(line) + let parts = split(a:line, '\t\zs') + let excmd = matchstr(parts[2:], '^.*\ze;"\t') + execute 'silent e' parts[1][:-2] + let [magic, &magic] = [&magic, 0] + execute excmd + let &magic = magic +endfunction + +function! s:tags() + if empty(tagfiles()) + echohl WarningMsg + echom 'Preparing tags' + echohl None + call system('ctags -R') + endif + + call fzf#run({ + \ 'source': 'cat '.join(map(tagfiles(), 'fnamemodify(v:val, ":S")')). + \ '| grep -v -a ^!', + \ 'options': '+m -d "\t" --with-nth 1,4.. -n 1 --tiebreak=index', + \ 'down': '40%', + \ 'sink': function('s:tags_sink')}) +endfunction + +command! Tags call s:tags() +map :Tags + +" Search lines in all open buffers +function! s:line_handler(l) + let keys = split(a:l, ':\t') + exec 'buf' keys[0] + exec keys[1] + normal! ^zz +endfunction + +function! s:buffer_lines() + let res = [] + for b in filter(range(1, bufnr('$')), 'buflisted(v:val)') + call extend(res, map(getbufline(b,0,"$"), 'b . ":\t" . (v:key + 1) . ":\t" . v:val ')) + endfor + return res +endfunction + +command! FZFLines call fzf#run({ +\ 'source': buffer_lines(), +\ 'sink': function('line_handler'), +\ 'options': '--extended --nth=3..', +\ 'down': '60%' +\}) + +" Select buffer +function! s:buflist() + redir => ls + silent ls + redir END + return split(ls, '\n') +endfunction + +function! s:bufopen(e) + execute 'buffer' matchstr(a:e, '^[ 0-9]*') +endfunction + +nnoremap :call fzf#run({ +\ 'source': reverse(buflist()), +\ 'sink': function('bufopen'), +\ 'options': '+m', +\ 'down': len(buflist()) + 2 +\ }) diff --git a/nvim/.config/nvim/search.vim b/nvim/.config/nvim/search.vim new file mode 100644 index 0000000..bd7aa54 --- /dev/null +++ b/nvim/.config/nvim/search.vim @@ -0,0 +1,13 @@ +" Search settings + +set ignorecase +set smartcase + +" Case-insensitive searching on normal mode +nnoremap * /\<=expand('')\> +nnoremap # ?\<=expand('')\> + +" Wrap scans at the bottom and top +set wrapscan + +" vim: ft=vim diff --git a/nvim/.config/nvim/spell/en.utf-8.add b/nvim/.config/nvim/spell/en.utf-8.add new file mode 100644 index 0000000..ee80367 --- /dev/null +++ b/nvim/.config/nvim/spell/en.utf-8.add @@ -0,0 +1,8 @@ +Thermophile +Halophiles +Coli +Nonpolar +Carboxyl +Amphipathic +triacylglycerol +Desynthesized diff --git a/nvim/.config/nvim/spell/en.utf-8.add.spl b/nvim/.config/nvim/spell/en.utf-8.add.spl new file mode 100644 index 0000000000000000000000000000000000000000..7e4d775de21486672f179630218e26fbc8e82bd6 GIT binary patch literal 201 zcmYL@K@P$o5JmYcdI@jgEnK+mexyW5Mrfc5>rFhZ{=p`a4E+50^O*T^?Q2v$f1Gpg zNy3uKh6h$8WZr^pr~vQ1R5aXB@x%@|cT(thGa@>@GSa3qUi2)pkfEIU5%q98okFj& fCnMK/dev/null diff --git a/zsh/.config/zsh/.zshenv b/zsh/.config/zsh/.zshenv new file mode 100755 index 0000000..2e7b483 --- /dev/null +++ b/zsh/.config/zsh/.zshenv @@ -0,0 +1,32 @@ +# Local Environment Variables +#export SSH_ASKPASS='/usr/bin/ksshaskpass ssh-add < /dev/null' + +#export FZF_DEFAULT_COMMAND="fd --threads $(nproc) --type f --hidden --color=never" + +# XDG Base Directory Support +export CARGO_HOME="${XDG_DATA_HOME}/.local/share}/cargo" +export GNUPGHOME="${XDG_DATA_HOME}/.local/share}/gnupg" +export GTK2_RC_FILES="${XDG_CONFIG_HOME}/.config}/gtk-2.0/gtkrc" +export _JAVA_OPTIONS="-Djava.util.prefs.userRoot=${XDG_CONFIG_HOME}/.config}/java" +export KDEHOME="${XDG_CONFIG_HOME}/.config}/kde" +export LESSHISTFILE="${XDG_CACHE_HOME}/.cache}/less/history" +export PASSWORD_STORE_DIR="${XDG_DATA_HOME}/password-store" +export PYLINT_HOME="${XDG_CACHE_HOME}/pylint" +export PYTHON_EGG_CACHE="${XDG_CACHE_HOME}/python-eggs" +export PYTHON_STARTUP="${XDG_CONFIG_HOME}/python/pythonrc" + +# nnn +#export NNN_OPTS_PROG=1 +#export NNN_TRASH=1 +#export NNN_USE_EDITOR=1 + +#export HOMEBREW_NO_AUTO_UPDATE=1 + +#export LD_LIBRARY_PATH="/Library/Developer/CommandLineTools/usr/lib/:$LD_LIBRARY_PATH" + +export PAGER="nvimpager" +export AUR_PAGER="ranger" + +# Manpager using vim/nvim +#export MANPAGER='nvim +Man!' +#export MANWIDTH=999 diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc new file mode 100755 index 0000000..bc72c77 --- /dev/null +++ b/zsh/.config/zsh/.zshrc @@ -0,0 +1,65 @@ +# User-specific zsh configuration + +# Default umask value +umask 0027 + +# ========== Functions ========== +# Fuzzy-find a file and open it in less +_run_fless() { + fless && zle reset-prompt +} + +zle -N _run_fless +bindkey -M viins '^n' _run_fless + +# Fuzzy find a file and then edit it + +_run_fedit() { + fedit && zle reset-prompt +} + +_run_etcedit() { + fedit --etc && zle reset-prompt +} + +zle -N _run_fedit +bindkey -M viins '^o' _run_fedit + +zle -N _run_etcedit +bindkey -M viins '^e' _run_etcedit + +# Fuzzy cd from anywhere +# Dependencies +# * fzf +# * mlocate + +cf() { + [[ -z "${*}" ]] && return 1 + [[ ! -x $(which fzf) ]] && return 1 + + #dir="$(locate --all --ignore-case --null -- "${@}" | fzf --read0 --select-1 --exit-0)" + #dir="$(locate -0i -- "${@}" | fzf --read0 --select-1 --exit-0)" + dir="$(fd --ignore-file "${XDG_CONFIG_HOME}/fd_ignore" --print0 --type d -- "${@}" | fzf --read0 --select-1 --exit-0)" + + [[ -z "${dir}" ]] && return 1 + + if [[ -f "${dir}" ]]; then + cd "${dir%/*}" + else + cd "${dir}" + fi +} + +autoload -Uz cf + +# Make a directory, then change into it + +mkcd() { + [[ ! -d "${1}" ]] && mkdir --parents -- "${1}" + cd "${1}" || exit +} + +autoload -Uz mkcd + +[ -f "${ZDOTDIR}/conf.d/fzf.zsh" ] && source "${ZDOTDIR}/conf.d/fzf.zsh" +test -e /Users/etorres/.config/zsh/.iterm2_shell_integration.zsh && source /Users/etorres/.config/zsh/.iterm2_shell_integration.zsh || true diff --git a/zsh/.config/zsh/conf.d/00-aliases.zsh b/zsh/.config/zsh/conf.d/00-aliases.zsh new file mode 100644 index 0000000..0b7e64a --- /dev/null +++ b/zsh/.config/zsh/conf.d/00-aliases.zsh @@ -0,0 +1,151 @@ +# ---------- Normal Aliases ---------- +# Common commands +alias cp='cp -piv' +alias mv='mv -iv' +# Use safe-rm instead of rm +alias rm='safe-rm -iv' +alias rmdir='rmdir -v' + +# Games +alias add-modrinth='ferium add-modrinth' + +# Git +alias gar='git archive' +alias gb='git branch' +alias gd='git diff' +alias ga='git add' +alias gc='git commit' +alias gca='git commit -a' +alias gco='git checkout' +alias gconf='${EDITOR} -- "${XDG_CONFIG_HOME:-${HOME}/.config}/git/config"' +alias gmv='git mv' +alias grm='git rm' +alias gs='git status' +alias gtv='printf "%s" "$(git describe --long | sed "s/\([^-]*-\)g/r\1/;s/-/./g")"' +alias gnv='printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"' +alias gr='git reset' + +# GPG +alias gdk='gpg --delete-keys' +alias gdsk='gpg --delete-secret-keys' +alias gik='gpg --import ' +alias gk='gpg --list-keys' +alias grk='gpg --receive-keys' +alias gsk='gpg --list-secret-keys' + +# Neomutt +alias neomuttconf='cd -- ${XDG_CONFIG_HOME:-${HOME}/.config}/neomutt' +alias neomuttrc='${EDITOR} ${XDG_CONFIG_HOME:-${HOME}/.config}/neomutt/neomuttrc' + +# Neovim +alias nvimcomm='${EDITOR} ${XDG_CONFIG_HOME:-${HOME}/.config}/nvim/commands' +alias nvimconf='cd "${XDG_CONFIG_HOME:-${HOME}/.config}/nvim"' +alias nvimft='cd "${XDG_DATA_HOME:-${HOME}/.local/share}/nvim/site/ftplugin"' +alias nvimplug='${EDITOR} -- "${XDG_CONFIG_HOME:-${HOME}/.config}/nvim/plugins.vim"' +alias nvimkey='${EDITOR} -- "${XDG_CONFIG_HOME:-${HOME}/.config}/nvim/keybindings.vim"' +alias nvimrc='${EDITOR} -- "${XDG_CONFIG_HOME:-${HOME}/.config}/nvim/init.vim"' +alias swapdir='cd -- "${XDG_DATA_HOME:-${HOME}/.local/share}/nvim/swap"' +alias vmore='nvim -u "${XDG_CONFIG_HOME:-${HOME}/.config}/nvim/pager.vim" -' + +#========= Package Management ========= +# Arch Linux +alias aurget='aur sync -d aur' +alias -g autoremove='pacman -Rns $(pacman -Qtdq)' +alias checkaurupdates='aur sync -d aur --upgrades' +# alias does not work correctly for some reason +alias lspkg="pacman -Qi | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -h" +alias ql='pacman -Qql' +alias pacsearch='pacman -Ss' +alias rpmget='aur sync -d rpm' +alias -g updatemirrors="reflector --verbose --country 'United States' --latest 200 --age 24 --sort rate --save /etc/pacman.d/mirrorlist" + +# ========== Packaging ========== +# Arch Linux +alias aurcache='cd ${XDG_CACHE_HOME}/aurutils/sync' +alias aurdir='cd /var/cache/pacman/aur' +alias customdir='cd /var/cache/pacman/custom' +alias gpkginit='cp /usr/share/pacman/PKGBUILD-vcs.proto ./PKGBUILD' +alias pkginit='cp /usr/share/pacman/PKGBUILD.proto ./PKGBUILD' +alias pa='makepkg --force --clean --cleanbuild --syncdeps --rmdeps && addpkg aur' +alias pc='makepkg --force --clean --cleanbuild --syncdeps --rmdeps && addpkg custom' +alias pr='makepkg --force --clean --cleanbuild --syncdeps --rmdeps && addpkg rpm' + +# Personal +alias :q='exit' +alias ct='cptemplate' +alias less='less -i --' +alias la='ls --almost-all --color --group-directories-first --human-readable -l' +alias ls='ls --color --group-directories-first' +alias ll='ls --classify --color --group-directories-first --human-readable -l' +alias python='python3' +alias spcli='speedtest-cli --secure' +alias sshconfig='"${EDITOR}" -- ${HOME}/.ssh/config' +alias tmux='tmux -f "${XDG_CONFIG_HOME:-${HOME}/.config}"/tmux/tmux.conf' +alias tmuxrc='nvim -- "${XDG_CONFIG_HOME:-${HOME}/.config}"/tmux/tmux.conf' +alias tuir='tuir --no-flash' +alias wget='wget --hsts-file="${XDG_DATA_HOME}/wget-hsts"' + +# Navigation +alias dirconf='"${EDITOR}" -- "${XDG_CONFIG_HOME:-${HOME}/.config}/user-dirs.dirs"' +alias dotfiles='cd "${HOME}/Dotfiles"' +alias xch='cd -- ${XDG_CONFIG_HOME:-${HOME}/.config}' +alias xcah='cd -- ${XDG_CACHE_HOME:-${HOME}/.cache}' +alias xdh='cd -- ${XDG_DATA_HOME:-${HOME}/.local/share}' + +# Programming +# Use python-pytest-xdist plugin +#alias pytest='pytest --numprocesses=$(nproc)' +alias pyarchive='git archive -o rbackup-"$(python setup.py --version)".tar.gz --prefix=rbackup-"$(python setup.py --version)"/' + +# ssh +alias scpe='scp -i "${HOME}/.ssh/empress"' + +# system +alias myip='curl ifconfig.me' +alias restartfans='sudo systemctl restart fancontrol.service' + +# zsh +alias zdotdir='cd -- ${ZDOTDIR:-${HOME}/.zsh}' +alias zshaliases='${EDITOR} -- ${ZDOTDIR:-${HOME}/.zsh}/conf.d/00-aliases.zsh' +alias zbindings='${EDITOR} -- ${ZDOTDIR:-${HOME}/.zsh}/conf.d/keybindings.zsh' +alias zconf='cd -- ${ZDOTDIR:-${HOME}/.zsh}/conf.d' +alias zfuncs='cd -- ${ZDOTDIR:-${HOME}/.zsh}/conf.d/functions' +alias zhist='${EDITOR} -- ${HISTFILE}' +alias zmod='cd -- ${ZDOTDIR:-${HOME}/.zsh}/conf.d/modules' +alias zpath='${EDITOR} -- ${ZDOTDIR:-${HOME}/.zsh}/conf.d/path.zsh' +alias zprompt='${EDITOR} -- ${ZDOTDIR:-${HOME}/.zsh}/conf.d/prompt.zsh' +alias zshrc='${EDITOR} -- ${ZDOTDIR:-${HOME}/.zsh}/.zshrc' +alias zshrefresh='source -- ${ZDOTDIR:-${HOME}/.zsh}/.zshrc' +alias zshenv='${EDITOR} -- ${ZDOTDIR:-${HOME}/.zsh}/.zshenv' + +# ---------- Parameterized Aliases ---------- +lsbin() { + if [[ -n $1 ]]; then + pacman -Qql $1 | rg bin + else + return 0 + fi +} + +rgenv () { + if [[ -n $1 ]]; then + env | rg --ignore-case $1 + else + return 0 + fi +} + +stow-config () { + local dotfile_dir="${HOME}/Dotfiles" + + for conf in "${@}"; do + if [[ -n ${conf} ]]; then + mkdir --parents "${dotfile_dir}/${conf}/.config" + mv "${XDG_CONFIG_HOME}/${conf}" "${dotfile_dir}/${conf}/.config" + cd "${dotfile_dir}" && stow "${conf}" + cd - + else + continue + fi + done +} diff --git a/zsh/.config/zsh/conf.d/00-keybindings.zsh b/zsh/.config/zsh/conf.d/00-keybindings.zsh new file mode 100644 index 0000000..dc9637e --- /dev/null +++ b/zsh/.config/zsh/conf.d/00-keybindings.zsh @@ -0,0 +1,4 @@ +# bindkey -M viins '^r' history-incremental-search-backward +# bindkey -M vicmd '^r' history-incremental-search-backward + +# vim: syntax=zsh diff --git a/zsh/.config/zsh/conf.d/completion.zsh b/zsh/.config/zsh/conf.d/completion.zsh new file mode 100644 index 0000000..03006d7 --- /dev/null +++ b/zsh/.config/zsh/conf.d/completion.zsh @@ -0,0 +1,27 @@ +## zsh-completion-generator +#GENCOMPL_FPATH="${HOME}/zsh-completions" +#source '/usr/share/zsh-completion-generator/zsh-completion-generator.plugin.zsh' + +autoload -Uz compinit +compinit + +# Tab completion menu +zstyle ':completion:*' menu select +zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} + +zstyle ':completion:*:*:kill:*' menu yes select +zstyle ':completion:*:kill:*' force-list always + +zstyle ':completion:*:*:killall:*' menu yes select +zstyle ':completion:*:killall:*' force-list always + +# Disabling this option enables tab completion for aliases +#setopt complete_aliases + +# Case insensitive completion +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' + +# Automatically load new executables +zstyle ':completion:*' rehash true + +# vim: syntax=zsh diff --git a/zsh/.config/zsh/conf.d/fzf.zsh b/zsh/.config/zsh/conf.d/fzf.zsh new file mode 100644 index 0000000..08e2c3f --- /dev/null +++ b/zsh/.config/zsh/conf.d/fzf.zsh @@ -0,0 +1,10 @@ +# Setup fzf +# --------- + +# Auto-completion +# --------------- +[[ $- == *i* ]] && source "/usr/share/fzf/completion.zsh" + +# Key bindings +# ------------ +source "/usr/share/fzf/key-bindings.zsh" diff --git a/zsh/.config/zsh/conf.d/kp.zsh b/zsh/.config/zsh/conf.d/kp.zsh new file mode 100644 index 0000000..afcaa08 --- /dev/null +++ b/zsh/.config/zsh/conf.d/kp.zsh @@ -0,0 +1,14 @@ +### PROCESS +# mnemonic: [K]ill [P]rocess +# show output of "ps -ef", use [tab] to select one or multiple entries +# press [enter] to kill selected processes and go back to the process list. +# or press [escape] to go back to the process list. Press [escape] twice to exit completely. + +kp() { + local pid=$(ps -ef | sed 1d | eval "fzf ${FZF_DEFAULT_OPTS} -m --header='[kill:process]'" | awk '{print $2}') + + if [[ -n "${pid}" && "${pid}" != "x" ]]; then + echo ${pid} | xargs kill -${1:-9} + kp + fi +} diff --git a/zsh/.config/zsh/conf.d/options b/zsh/.config/zsh/conf.d/options new file mode 100644 index 0000000..c994936 --- /dev/null +++ b/zsh/.config/zsh/conf.d/options @@ -0,0 +1,14 @@ +# automatically cd into a given directory +setopt autocd + +# history options +setopt append_history +setopt hist_ignore_all_dups + +# command correction +setopt correctall + +# prevent accidental overwriting of a file +setopt noclobber + +# vim: syntax=zsh diff --git a/zsh/.config/zsh/conf.d/path.zsh b/zsh/.config/zsh/conf.d/path.zsh new file mode 100644 index 0000000..a376e23 --- /dev/null +++ b/zsh/.config/zsh/conf.d/path.zsh @@ -0,0 +1,4 @@ +# PATH variable configuration +path=("${HOME}/Scripts/Arch Linux Helpers" $path) + +export PATH diff --git a/zsh/.config/zsh/conf.d/prompt.zsh b/zsh/.config/zsh/conf.d/prompt.zsh new file mode 100644 index 0000000..9349f4f --- /dev/null +++ b/zsh/.config/zsh/conf.d/prompt.zsh @@ -0,0 +1,35 @@ +# allows substitution in the prompt +setopt PROMPT_SUBST + +# ========== VCS info ========== +autoload -Uz vcs_info +zstyle ':vcs_info:*' enable git +zstyle ':vcs_info:*' check-for-changes true +#zstyle ':vcs_info:git*' formats "%{$fg[grey]%} %{$fg[blue]%}%b%{$reset_color%}%m %u %c%{$reset_color%}" +zstyle ':vcs_info:git*' formats "%{$fg[grey]%}%{$fg[blue]%}%b%{$reset_color%}%m %u %c%{$reset_color%}" + +# ========== Vim Command Mode ========== +vim_ins_mode='ins' +vim_cmd_mode='cmd' +vim_mode=${vim_ins_mode} + +zle-keymap-select() { + vim_mode="${${KEYMAP/vicmd/${vim_cmd_mode}}/(main|viins)/${vim_ins_mode}}" + zle reset-prompt +} +zle -N zle-keymap-select + +zle-line-finish() { + vim_mode=${vim_ins_mode} +} +zle -N zle-line-finish + +# ========== Final Prompt ========== +precmd() { + vcs_info +} + +#PS1='%F{blue}%n%f@%m %F{green}%3~%f > ' +#RPS1='%F{green}${vim_mode}%f ${vcs_info_msg_0_} [%F{red}%?%f]' +PS1='%F{green}%3~%f %F{blue}>%f ' +RPS1='${vcs_info_msg_0_} [%F{red}%?%f]' diff --git a/zsh/.config/zsh/conf.d/sudo.zsh b/zsh/.config/zsh/conf.d/sudo.zsh new file mode 100644 index 0000000..eaa672c --- /dev/null +++ b/zsh/.config/zsh/conf.d/sudo.zsh @@ -0,0 +1,23 @@ +# Press escape twice to prepend the previous command with "sudo" +sudo-command-line() { + [[ -z ${BUFFER} ]] && zle up-history + if [[ ${BUFFER} == sudo\ * ]]; then + LBUFFER="${LBUFFER#sudo }" + elif [[ ${BUFFER} == $EDITOR\ * ]]; then + LBUFFER="${LBUFFER#$EDITOR }" + LBUFFER="sudoedit $LBUFFER" + elif [[ ${BUFFER} == sudoedit\ * ]]; then + LBUFFER="${LBUFFER#sudoedit }" + LBUFFER="$EDITOR $LBUFFER" + else + LBUFFER="sudo $LBUFFER" + fi +} + +zle -N sudo-command-line + +# Defined shortcut keys: [Esc] [Esc] +bindkey -M viins "\e\e" sudo-command-line +bindkey -M vicmd "\e\e" sudo-command-line + +# vim: syntax=zsh diff --git a/zsh/.config/zsh/conf.d/tmux.zsh b/zsh/.config/zsh/conf.d/tmux.zsh new file mode 100644 index 0000000..9b59e9e --- /dev/null +++ b/zsh/.config/zsh/conf.d/tmux.zsh @@ -0,0 +1,13 @@ +## load a tmux session +_load_tmux() { + if [[ -n "${TMUX}" ]]; then + echo "Already in a tmux session." + else + tmux + fi +} + +zle -N _load_tmux +bindkey -M viins "^y" _load_tmux + +# vim: syntax=zsh