From 9be33b8eac2deab829dfef737173c8a97f4f9cfa Mon Sep 17 00:00:00 2001 From: punkfairie <23287005+punkfairie@users.noreply.github.com> Date: Sun, 10 Mar 2024 15:45:03 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(fish):=20hack=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `hack` no longer cd's to ~/hackin/. It is now a function that allows the user to select from their Github repositories, clone it if it doesn't exist, and enter the project directory. --- .config/fish/conf.d/20-aliases.fish | 5 ----- .config/fish/functions/hack.fish | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .config/fish/functions/hack.fish diff --git a/.config/fish/conf.d/20-aliases.fish b/.config/fish/conf.d/20-aliases.fish index 926414a..198e6d6 100644 --- a/.config/fish/conf.d/20-aliases.fish +++ b/.config/fish/conf.d/20-aliases.fish @@ -10,11 +10,6 @@ abbr -a v --position command "$EDITOR" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Location aliases. -abbr -a hack --position command "cd $HACK" - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Default command options. abbr -a cp --position command "cp -iv" diff --git a/.config/fish/functions/hack.fish b/.config/fish/functions/hack.fish new file mode 100644 index 0000000..a53f322 --- /dev/null +++ b/.config/fish/functions/hack.fish @@ -0,0 +1,15 @@ +#!/usr/bin/env fish + +function hack --description "Select a GH repo, [clone it], enter its directory" + set -f repos $(gh repo list --source --no-archived --json name,description --jq '.[] | "\(.name) \u001b[1;30m\(.description)\u001b[0m"') + set -f repo $(gum filter --height 10 $repos | string split ' ')[1] + + set -f path "$HOME/hackin/$repo" + + if test ! -d $path + echo "Cloning $repo into $path..." + gh repo clone $repo $path + end + + cd $path +end