Update for latest fzf and add a few additional scripts
This commit is contained in:
parent
f9731dd7ca
commit
fe69664195
8 changed files with 285 additions and 204 deletions
36
flake.nix
Normal file
36
flake.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
description = "Nix q.sh dev environment";
|
||||
|
||||
# Flake inputs
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||
};
|
||||
|
||||
# Flake outputs
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
# Systems supported
|
||||
allSystems = [
|
||||
"x86_64-linux" # 64-bit Intel/AMD Linux
|
||||
"aarch64-linux" # 64-bit ARM Linux
|
||||
"x86_64-darwin" # 64-bit Intel macOS
|
||||
"aarch64-darwin" # 64-bit ARM macOS
|
||||
];
|
||||
|
||||
# Helper to provide system-specific attributes
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
});
|
||||
in
|
||||
{
|
||||
# Development environment output
|
||||
devShells = forAllSystems ({ pkgs }: {
|
||||
default = pkgs.mkShell {
|
||||
# The Nix packages provided in the environment
|
||||
packages = with pkgs; [
|
||||
fzf
|
||||
];
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
6
q
6
q
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
#
|
||||
# Distributed under the terms of the BSD License
|
||||
#
|
||||
|
@ -32,7 +32,7 @@ if [[ -z "$Q_SCRIPT_DIR" ]]; then
|
|||
Q_SCRIPT_DIR=~/.config/q.sh
|
||||
fi
|
||||
|
||||
SELF="$0"
|
||||
SELF=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)/$(basename -- "$0")")
|
||||
|
||||
INDEX_FILE=~/.q.index
|
||||
HINT_FILE=~/.q.hints
|
||||
|
@ -198,7 +198,7 @@ if [[ -z "$COMMAND" ]]; then
|
|||
PREF="$SELF -c"
|
||||
INITIAL=""
|
||||
FZF_DEFAULT_COMMAND="$PREF '$INITIAL'" fzf \
|
||||
--bind "change:reload:$PREF {q} || true" \
|
||||
--bind "change:reload-sync:$PREF {q} || true" \
|
||||
--ansi --query "$INITIAL" \
|
||||
--preview "$SELF -p {}" \
|
||||
--with-nth="2..-1" \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
if [[ -z "$@" ]]; then
|
||||
|
|
19
q-browse
Executable file
19
q-browse
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [[ -z "$@" ]]; then
|
||||
echo "^f .*$"
|
||||
elif [[ "$1" == "--hint" ]]; then
|
||||
shift
|
||||
elif [[ "$1" == "--complete" ]]; then
|
||||
shift
|
||||
echo "0 $@"
|
||||
elif [[ "$1" == "--preview" ]]; then
|
||||
shift
|
||||
URL="$(echo "$@" | cut -d ' ' -f3-)"
|
||||
echo "Will open '$URL' in firefox"
|
||||
elif [[ "$1" == "--run" ]]; then
|
||||
shift
|
||||
URL="$(echo "$@" | cut -d ' ' -f3-)"
|
||||
(nohup xdg-open "$URL" 2>/dev/null &)
|
||||
sleep 0.01
|
||||
fi
|
2
q-calc
2
q-calc
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
calc() {
|
||||
res="$(echo "$1" | bc 2>/dev/null)"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
if [[ -z "$@" ]]; then
|
||||
|
|
2
q-pass
2
q-pass
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
if [[ -z "$@" ]]; then
|
||||
# Return a regular expression that should trigger
|
||||
|
|
26
q-run
Executable file
26
q-run
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
|
||||
export PATH=~/.prefix/bin:~/.local/bin:$PATH
|
||||
|
||||
find_all_executables() {
|
||||
{
|
||||
IFS=:; for d in $PATH; do for f in $d/*; do [ -f $f ] && [ -x $f ] && echo ${f##*/}; done; done;
|
||||
} | sort
|
||||
#flatpak --columns=application --app list | tail -n +1 | awk '{print "flatpak run " $0}';
|
||||
}
|
||||
|
||||
if [[ -z "$@" ]]; then
|
||||
echo "^run [a-zA-Z0-9_-]*$"
|
||||
elif [[ "$1" == "--hint" ]]; then
|
||||
find_all_executables | awk '{print $1 " run " $1}'
|
||||
elif [[ "$1" == "--complete" ]]; then
|
||||
shift
|
||||
find_all_executables | awk '{print $1 " run " $1}'
|
||||
elif [[ "$1" == "--preview" ]]; then
|
||||
shift
|
||||
echo "Will run $1"
|
||||
elif [[ "$1" == "--run" ]]; then
|
||||
shift
|
||||
(nohup "$1" 2>/dev/null &)
|
||||
sleep 0.01
|
||||
fi
|
Loading…
Reference in a new issue