Skip to content

Instantly share code, notes, and snippets.

@RRethy
RRethy / directory_jumper.zsh
Last active May 17, 2021 16:16
A small ZSH script to replace autojump
# Usage: `jd `
# Make after typing j, d, and a space, fzy will pop up offering a fuzzy selector.
# Setup some data a data file to store visited directories
mkdir -p "$XDG_DATA_HOME/zshrc"
JD_DATA_DIR="$XDG_DATA_HOME/zshrc/chpwd.txt"
touch $JD_DATA_DIR
local tmp=$(mktemp)
cat $JD_DATA_DIR | while read dir ; do [[ -d $dir ]] && echo $dir ; done > $tmp
cat $tmp > $JD_DATA_DIR
@RRethy
RRethy / reactive_input_old.vim
Created January 3, 2019 23:56
React to user input as it is typed - Old Method
fun! QueryInput() abort
let c = ''
" Builds a basic prompt
echohl Keyword | echon 'Input: ' | echohl None
while 1
let nbr = getchar()
" Check if no character button was clicked
@RRethy
RRethy / reactive_input_new.vim
Last active January 4, 2019 00:06
React to user input as it is typed
fun! QueryInput() abort
" Set up the autocmd to react to the user typing
augroup textwatcher
autocmd!
autocmd CmdlineChanged * call s:on_text_changed()
augroup END
" Request input from the user
let search = input('Input: ')
@RRethy
RRethy / gist:ad8a9a3b1112a48226ec3336fa981224
Last active May 1, 2024 03:05
Seamlessly editing remote files in (Neo)Vim with Netrw and scp

Seamlessly editing remote files in (Neo)Vim with Netrw and scp

Neovim and Vim both come bundled with a standard plugin called Netrw. Netrw acts a file explorer (similar to NERDTree), but more importantly has the ability to work with scp (as well as sftp, rcp, ftp, and lots of others :h netrw-nread) to let you edit files and browse directories that are hosted on a remote machine, inside of your local Vim instance.

This is useful since you are able to use your Vim setup and plugins without copying over your dotfiles to the remote machine. As well, since the file is copied to your local machine, there will be no delay when typing.

Setup

This is optional for Vim, but required for Neovim (check this Neovim issue explaining why).