aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/,
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/,')
-rwxr-xr-x.local/bin/,93
1 files changed, 78 insertions, 15 deletions
diff --git a/.local/bin/, b/.local/bin/,
index e1ed37d..2fb22e8 100755
--- a/.local/bin/,
+++ b/.local/bin/,
@@ -4,9 +4,8 @@
program=$(basename "$0")
requires="$(command -V nix-index nix-locate nix-shell fzf | awk '{ print $1, $3 }' | column -t)"
-[ "${1:-}" = "--check" ] && printf '%s\n' "$requires" && exit;
-
-{ [ "${1:-}" = "--help" ] || [ "$#" = 0 ]; } && printf \
+help() {
+printf \
"
Usage: %s [FLAGS]... [ARGUMENT]...
@@ -15,26 +14,90 @@ packages for a file and set up a nix shell for the
program that contains that file. The shell prints
all binaries in the package upon invocation.
+Create and update the file database by running
+the nix-index command. Warning: This command uses
+up a large amount of memory.
+
+nix-index --nixpkgs https://github.com/NixOS/nixpkgs/archive/master.tar.gz
+
Command List:
$program [ARGUMENT]... Search for packages using file name argument.
$program --help Show this help menu.
$program --check Check dependencies.
-" "$program" && exit;
+" "$program"
+}
+
+[ "${1:-}" = "--check" ] && printf '%s\n' "$requires" && exit
+
+{ [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ] || [ "$#" = 0 ]; } && help && exit
+
+databasePath=${XDG_DATA_HOME:-~/.cache}/nix-index
+nixLocate='nix-locate --db '"$databasePath"' --no-group --regex -- '"${1:-}"
+attributes=$($nixLocate | awk '{ print $1, $4 }' | sed 's|/nix/store/.[^-]*-||g')
-databasePath=${XDG_DATA_HOME:-~/.local/share}/nix-index
-nixLocate='nix-locate --db '"$databasePath"' --top-level --minimal --whole-name '"${1:-}"
-attributes=$($nixLocate | while read -r attribute; do
- attributeName=${attribute%.*};
- printf '%s\n' "$attributeName";
-done)
+[ -z "$attributes" ] && printf "No files found containing '%s'\n" "${1:-}" && exit
-attribute=$(printf '%s' "$attributes" | fzf)
-nix-shell --packages "$attribute" --command \
+option=$(printf '%s' "$attributes" | column --table | fzf)
+attribute=${option%% *}
+file=${option#*/}
+
+[ -z "$attribute" ] && exit
+
+printf '\nsetting up shell with %s path...\n' "$attribute"
+printf '\n$OUT/%s\n' "$file"
+
+nix-shell --option substituters 'https://cache.nixos.org' --packages "$attribute" fish bat toybox --command \
'
+ home=$TMPDIR/nix-shell-tmp-home.r2np9PHrby
+ program=$(printf "%s" "$buildInputs" | cut --delimiter=" " --fields=1)
+ path=$(IFS=" " && for buildInput in $buildInputs; do printf "%s/bin " "$buildInput"; done | sed "s/ /:/g")
printf "\n";
- ls $buildInputs/bin;
+ { [ -d "$program/bin" ] && ls "$program/bin"; } || printf "%s\n" "$program";
printf "\n";
- tree -L 1 $buildInputs;
- return
+ tree -L 1 "$program";
+ printf "\n";
+
+ /usr/bin/env --ignore-environment /bin/sh -c \
+ "
+ export PATH=$path
+ export DISPLAY=$DISPLAY
+ export XAUTHORITY=$XAUTHORITY
+ export TERM=$TERM
+ export TERMINFO=$TERMINFO
+ export TERMINFO_DIRS=$TERMINFO_DIRS
+ export HOME=$home
+ export OUT=$program
+ export fish_greeting=
+ mkdir --parents $home
+ cd || exit 1
+ fish --init-command=\"
+ function fish_prompt; printf '"'nix-shell@$attribute $ '"'; end
+ set -U fish_color_normal B3B1AD
+ set -U fish_color_command 39BAE6
+ set -U fish_color_quote C2D94C
+ set -U fish_color_redirection FFEE99
+ set -U fish_color_end F29668
+ set -U fish_color_error FF3333
+ set -U fish_color_param 39BAE6
+ set -U fish_color_comment 626A73
+ set -U fish_color_match F07178
+ set -U fish_color_selection E6B450
+ set -U fish_color_search_match E6B450
+ set -U fish_color_history_current --bold
+ set -U fish_color_operator E6B450
+ set -U fish_color_escape 95E6CB
+ set -U fish_color_cwd 59C2FF
+ set -U fish_color_cwd_root red
+ set -U fish_color_valid_path --underline
+ set -U fish_color_autosuggestion aaaaaa
+ set -U fish_color_user brgreen
+ set -U fish_color_host normal
+ set -U fish_color_cancel -r
+ set -U fish_pager_color_completion normal
+ set -U fish_pager_color_description B3A06D yellow
+ set -U fish_pager_color_prefix white --bold --underline
+ set -U fish_pager_color_progress brwhite --background=cyan
+ \"
+ "
';