Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vifon
vifon / ripegrape
Created March 30, 2022 00:18
Ripe Grape - A fzf-based wrapper around ripgrep.
#!/usr/bin/env bash
# Ripe Grape - A fzf-based wrapper around ripgrep.
set -o errexit -o nounset -o pipefail
rg --color=always --line-number --with-filename "$@" \
| fzf --ansi --reverse \
--delimiter=: \
--bind 'ctrl-v:execute(vim +{2} {1})' \
@vifon
vifon / find-remains.sh
Created February 23, 2022 16:17
Check for the remains of a program in the most likely places.
#!/usr/bin/env fish
# Check for the remains of a program in the most likely places.
# Useful when testing new software or removing no longer used one.
if command -v exa > /dev/null
set ls exa
else
set ls ls --color=auto
end
@vifon
vifon / xpipe
Created July 25, 2020 01:32
Print to stdout each new X11 selection value separated by a single newline
#!/bin/bash
# Print to stdout each new X11 selection value. By default operates
# on "xsel -b". Any passed arguments are used instead of
# "-b" verbatim.
set -o errexit -o nounset -o pipefail
# Set argv to -b (operating on the CLIPBOARD selection) if
@vifon
vifon / firefox-vanilla
Created April 18, 2019 19:45
Start an absolutely fresh Firefox instance that's self-destruct afterwards
#!/bin/bash
finish() {
rm -rf "$TMP"
exit
}; trap finish EXIT INT TERM
TMP="$(mktemp -d -t prefix.XXXXXX --tmpdir=/tmp)"
env HOME="$TMP" firefox -no-remote "$@"
@vifon
vifon / commands.py
Last active August 23, 2018 20:41
ranger 2-way chdir
# Patched from ranger commit 8d4808fc
class shell(Command):
escape_macros_for_shell = True
def execute(self):
if self.arg(1) and self.arg(1)[0] == '-':
flags = self.arg(1)[1:]
command = self.rest(2)
else:
@vifon
vifon / dotify
Last active June 15, 2018 00:27
Toggle the leading dot in files
#!/bin/zsh
for file in "$@"; do
if [[ "$file:t" = .* ]]; then
mv -v -- "$file" "${file:h}/${${file:t}#.}"
else
mv -v -- "$file" "${file:h}/.${file:t}"
fi
done
@vifon
vifon / pod-refuck.pl
Last active May 24, 2018 12:27
Make the heavily nested Perl docs more readable (though invalid POD)
#!/usr/bin/env perl
use warnings;
use strict;
use 5.010;
use constant INDENT_WIDTH => 2;
my $indent_level = 0;
Index: b/ranger/gui/widgets/view_base.py
===================================================================
--- a/ranger/gui/widgets/view_base.py
+++ b/ranger/gui/widgets/view_base.py
@@ -112,15 +112,17 @@ class ViewBase(Widget, DisplayableContai
self.color_reset()
self.need_clear = True
hints = []
- for key, value in self.fm.ui.keybuffer.pointer.items():
- key = key_to_string(key)
@vifon
vifon / jinja-render.py
Created September 30, 2017 11:05
Jinja2 environment variable renderer
#!/usr/bin/env python3
from jinja2 import Template
import argparse
import os
def main(argv=None):
parser = argparse.ArgumentParser()
parser.add_argument('input_file', type=argparse.FileType('r'))
@vifon
vifon / lsblk.pl
Last active July 15, 2017 23:37
lsblk fix for Linux 4.8
#!/usr/bin/env perl
=head1 Fix lsblk on Linux 4.8
On Linux 4.8 the order of devices is screwed up. Let's sort it manually.
=cut
use warnings;
use strict;