From 6a4a145c0468ec6922fc4ca5037088a5b538c630 Mon Sep 17 00:00:00 2001 From: Steffen Rademacker Date: Wed, 27 Jan 2021 20:44:04 +0100 Subject: [PATCH] NNN, jump and other funky new stuff. Giving it a try... --- install/cli-tools.sh | 4 ++++ install/node.sh | 1 - nvim/init.vim | 2 +- nvim/plugins.vim | 6 +++++- zsh/aliases | 19 ++----------------- zsh/exports | 10 ++++++++++ zsh/functions | 44 ++++++++++++++++---------------------------- zsh/zshrc | 9 ++++----- 8 files changed, 42 insertions(+), 53 deletions(-) diff --git a/install/cli-tools.sh b/install/cli-tools.sh index 744fa0e..294882b 100755 --- a/install/cli-tools.sh +++ b/install/cli-tools.sh @@ -9,13 +9,17 @@ brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-fdk-aac brew install htop brew install httpd brew install imagemagick +brew install jump brew install mariadb brew install mkcert +brew install nnn brew install nss brew install openssl brew install php@7.4 brew install ripgrep brew install switchaudio-osx +brew install trash-cli +brew install tree # dnsmasq echo 'address=/.localhost/127.0.0.1' > /usr/local/etc/dnsmasq.conf diff --git a/install/node.sh b/install/node.sh index fc0d1db..f5c1623 100755 --- a/install/node.sh +++ b/install/node.sh @@ -9,5 +9,4 @@ npm install -g fkill-cli npm install -g neovim npm install -g npm-check npm install -g pure-prompt -npm install -g trash-cli npm install -g yarn diff --git a/nvim/init.vim b/nvim/init.vim index ed9487d..a597394 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -9,6 +9,7 @@ if dein#load_state('~/.cache/dein') call dein#add('junegunn/fzf', { 'merged': 0 }) call dein#add('junegunn/fzf.vim', { 'depends': 'fzf' }) call dein#add('junegunn/gv.vim') + call dein#add('mcchrish/nnn.vim') call dein#add('neoclide/coc.nvim', { 'merged': 0, 'rev': 'release' }) call dein#add('sheerun/vim-polyglot') call dein#add('tpope/vim-apathy') @@ -20,7 +21,6 @@ if dein#load_state('~/.cache/dein') call dein#add('tpope/vim-repeat') call dein#add('tpope/vim-surround') call dein#add('tpope/vim-unimpaired') - call dein#add('tpope/vim-vinegar') call dein#add('w0ng/vim-hybrid') call dein#add('wellle/targets.vim') call dein#add('wellle/tmux-complete.vim') diff --git a/nvim/plugins.vim b/nvim/plugins.vim index 16fe054..36b16ef 100644 --- a/nvim/plugins.vim +++ b/nvim/plugins.vim @@ -12,6 +12,11 @@ nnoremap l :Lines nnoremap a :Rg nnoremap h :History: +" nnn integration +let g:nnn#set_default_mappings = 0 +let g:nnn#command = 'nnn -deH' +nnoremap - :NnnPicker %:p:h + " EasyMotion let g:EasyMotion_do_mapping=0 let g:EasyMotion_smartcase=1 @@ -68,7 +73,6 @@ nmap (coc-range-select) xmap (coc-range-select) " Map function and class text objects -" NOTE: Requires 'textDocument.documentSymbol' support from the language server. xmap if (coc-funcobj-i) omap if (coc-funcobj-i) xmap af (coc-funcobj-a) diff --git a/zsh/aliases b/zsh/aliases index 6fb33c5..3ab5794 100644 --- a/zsh/aliases +++ b/zsh/aliases @@ -1,20 +1,13 @@ -# make aliases and other stuff work in sudo +# Make aliases and other stuff work in sudo alias sudo='sudo ' - -# always use nvim, see exports alias vim=$EDITOR alias vi=$EDITOR alias v=$EDITOR alias vimdiff='$EDITOR -d' alias vdiff='$EDITOR -d' alias vd='$EDITOR -d' - -# Easier navigation: .., ..., ~ and - -alias ~="cd ~" alias ..='cd ..' alias ...='cd ../..' -alias ....='cd ../../..' -alias .....='cd ../../../..' alias q='exit' # suffix-aliases for file-types (zsh only) @@ -28,12 +21,9 @@ alias -s scss=$EDITOR alias -s txt=$EDITOR alias -s yaml=$EDITOR -# better ls / l command -alias l='ls -alGp' - # mutt +alias mutt='neomutt' alias m='neomutt' -# alias for syncing everything alias O="cd ~ && mbsync -a && mu index && vdirsyncer sync" # Gitty gitgit @@ -68,11 +58,6 @@ alias ys='yarn develop' alias yp='yarn lint && yarn production' alias yre='rm -f yarn.lock && rm -rf node_modules && yarn' -# often used folder shortcuts -alias web='cd ~/Sites && l' -alias rep='cd ~/Repositories && l' -alias dot='cd ~/Dotfiles && l' - # random usefull stuff alias dnsflush='sudo dscacheutil -flushcache' alias lock="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend" diff --git a/zsh/exports b/zsh/exports index 5aa52ff..8372554 100644 --- a/zsh/exports +++ b/zsh/exports @@ -47,3 +47,13 @@ export RIPGREP_CONFIG_PATH="$HOME/dotfiles/ripgreprc" export PAGER="less" export LESS="-R" export LC_CTYPE=$LANG + +# nnn +export NNN_BMS='d:~/Dotfiles;s:~/Sites;l:~/Downloads;h:~/' +export NNN_FIFO='/tmp/nnn.fifo' +export NNN_TRASH=1 +export NNN_PLUG='o:fzcd;j:autojump;p:preview-tui' +export NNN_ARCHIVE="\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$" + +# n node version management +export N_PREFIX="$HOME/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin" # Added by n-install (see http://git.io/n-install-repo). diff --git a/zsh/functions b/zsh/functions index e487f5a..2b248d1 100644 --- a/zsh/functions +++ b/zsh/functions @@ -26,6 +26,22 @@ webvideoposter () { ffmpeg -ss 00:00:02 -i $1 -frames:v 1 $1.jpg } +l () { + if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then + echo "nnn is already running" + return + fi + + export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" + + nnn -deH "$@" + + if [ -f "$NNN_TMPFILE" ]; then + . "$NNN_TMPFILE" + rm -f "$NNN_TMPFILE" > /dev/null + fi +} + # create and change to directory/folder take () { mkdir -p $1 @@ -50,34 +66,6 @@ fancy-ctrl-z () { fi } -# creates an archive from given directory -mktar () { tar cvf "${1%%/}.tar" "${1%%/}"; } -mktgz () { tar cvzf "${1%%/}.tgz" "${1%%/}"; } -mkzip () { zip -r "${1%%/}" "${1%%/}"; } - -# easy extract -extract () { - if [ -f $1 ] ; then - case $1 in - *.tar.bz2) tar xvjf $1 ;; - *.tar.gz) tar xvzf $1 ;; - *.bz2) bunzip2 $1 ;; - *.rar) rar x $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xvf $1 ;; - *.tgz) tar xvzf $1 ;; - *.tbz2) tar xvjf $1 ;; - *.tbz) tar xvjf $1 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1 ;; - *.7z) 7z x $1 ;; - *) echo "don't know how to extract '$1'..." ;; - esac - else - echo "'$1' is not a valid file!" - fi -} - wttr () { if [[ -n "$1" ]] then diff --git a/zsh/zshrc b/zsh/zshrc index 6880b2d..28684f2 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -46,14 +46,12 @@ setopt hist_ignore_space setopt hist_verify setopt inc_append_history setopt share_history +setopt long_list_jobs # smart urls autoload -U url-quote-magic zle -N self-insert url-quote-magic -# jobs -setopt long_list_jobs - # source some zsh plugins source $HOME/dotfiles/zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh source $HOME/dotfiles/zsh/zsh-completions/zsh-completions.plugin.zsh @@ -61,7 +59,8 @@ source $HOME/dotfiles/zsh/zsh-completions/zsh-completions.plugin.zsh # fzf [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh +# jump +eval "$(jump shell)" + # zsh-completions fpath=($HOME/dotfiles/zsh/zsh-completions/src $fpath) - -export N_PREFIX="$HOME/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin" # Added by n-install (see http://git.io/n-install-repo).