mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-06 20:10:14 +00:00
packaging stuff up
This commit is contained in:
25
pkgs/tools/misc/jqr/jqr.sh
Executable file
25
pkgs/tools/misc/jqr/jqr.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Adapted from: https://gist.github.com/reegnz/b9e40993d410b75c2d866441add2cb55
|
||||
|
||||
if [[ -z $1 ]] || [[ $1 == "-" ]]; then
|
||||
input=$(mktemp)
|
||||
trap 'rm -f $input' EXIT
|
||||
cat /dev/stdin >"$input"
|
||||
else
|
||||
input=$1
|
||||
fi
|
||||
|
||||
# TODO: make available on non-macOS
|
||||
|
||||
echo '' |
|
||||
fzf --phony \
|
||||
--height 100% \
|
||||
--preview-window='up:80%' \
|
||||
--query '.' \
|
||||
--print-query \
|
||||
--header $'CTRL-O: jq output\nCTRL-Y: copy output\nALT-Y: copy query' \
|
||||
--preview "jq --color-output -r {q} $input" \
|
||||
--bind "ctrl-o:execute(jq -r {q} $input)+clear-query+accept" \
|
||||
--bind "alt-y:execute(echo {q} | pbcopy)" \
|
||||
--bind "ctrl-y:execute(jq -r {q} $input | pbcopy)"
|
10
pkgs/tools/misc/jqr/package.nix
Normal file
10
pkgs/tools/misc/jqr/package.nix
Normal file
@ -0,0 +1,10 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "jqr";
|
||||
runtimeInputs = [
|
||||
pkgs.jq
|
||||
pkgs.fzf
|
||||
];
|
||||
text = builtins.readFile ./jqr.sh;
|
||||
}
|
Reference in New Issue
Block a user