Skip to content

Instantly share code, notes, and snippets.

@srijanshetty
srijanshetty / redir.md
Created April 17, 2020 05:15 — forked from romainl/redir.md
Redirect the output of a Vim or external command into a scratch buffer

Redirect the output of a Vim or external command into a scratch buffer

Usage (any shell)

Show full output of command :hi in scratch window:

:Redir hi

Show full output of command :!ls -al in scratch window:

Vim: pushing built-in features beyond their limits

The situation

Searching can be an efficient way to navigate the current buffer.

The first search commands we learn are usually / and ?. These are seriously cool, especially with the incsearch option enabled which lets us keep typing to refine our search pattern. / and ? really shine when all we want is to jump to something we already have our eyeballs on but they are not fit for every situation:

  • when we want to search something that's not directly there, those two commands can make us loose context very quickly,
  • when we need to compare the matches.

Vim: pushing built-in features beyond their limits

The situation

Searching can be an efficient way to navigate the current buffer.

The first search commands we learn are usually / and ?. These are seriously cool, especially with the incsearch option enabled which lets us keep typing to refine our search pattern. / and ? really shine when all we want is to jump to something we already have our eyeballs on but they are not fit for every situation:

  • when we want to search something that's not directly there, those two commands can make us loose context very quickly,
  • when we need to compare the matches.
@srijanshetty
srijanshetty / git-fshow
Last active May 28, 2019 20:36 — forked from akatrevorjay/git-fshow
Browsing git commit history with fzf
#!/bin/zsh
# git-fshow - git commit browser
#
# https://gist.github.com/akatrevorjay/9fc061e8371529c4007689a696d33c62
# https://asciinema.org/a/101366
#
git-fshow() {
local g=(
git log
@srijanshetty
srijanshetty / git-hook-pdf2htmlEX
Created May 21, 2015 07:04
Git Hook for pdf2htmlEX
#!/usr/bin/env bash
set -e
branch=$(git rev-parse --abbrev-ref HEAD)
if [[ $branch == "master" ]]; then
xelatex cv
git checkout gh-pages
pdf2htmlEX --process-outline 0 --zoom 1.6 cv.pdf
@srijanshetty
srijanshetty / vagrant-lamp
Created May 21, 2015 07:03
Vagrant File for lampbox
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.hostname = "scotchbox"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
@srijanshetty
srijanshetty / zsh-static-completions
Created May 21, 2015 05:21
ZSH static completions
#compdef repos
typeset -A opt_args
local context state line
_arguments -s -S \
'--add-git[add a github configuration]'\
'--add-bit[add a bitbucket configuration]'\
'--available[List all available configurations.]'\
'--check[list all repos not in mrconfig]'\

If you're using GNU make and you need help debugging a makefile then there's a single line your should add. And it's so useful that you should add it to every makefile you create.

It's:

print-%: ; @echo $=$($) It allows you to quickly get the value of any makefile variable. For example, suppose you want to know the value of a variable called SOURCE_FILES. You'd just type:

make print-SOURCE_FILES If you are using GNU make 3.82 or above it's not even necessary to modify the makefile itself. Just do

@srijanshetty
srijanshetty / ramda
Last active August 29, 2015 14:20 — forked from raine/ramda
Ramda documentation browser using command line
#!/usr/bin/env bash
# Browse Ramda documentation in Terminal
# Requires jq and a tool such as fzf or peco for interactive filtering
LATEST="https://raw.githubusercontent.com/raine/ramda-json-docs/gh-pages/latest.json"
DOCS_URL="http://ramdajs.com/docs/"
json=$(curl -s $LATEST)
functions=$(echo "$json" | jq -r '.[] | if .sig and (.sig | length > 0) then .name + " :: " + .sig else .name end')
@srijanshetty
srijanshetty / zsh-dynamic-completions
Last active August 29, 2015 14:16
ZSH dynamic completions
#compdef savesolarized
_arguments "1: :($(lssolarized | tr "\n" " "))"