From 1e2a7faa3c87a74ac1824d033b64804fd86d9ecc Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 8 Oct 2023 16:34:00 +0200 Subject: [PATCH] Add makeaway function --- .config/fish/functions/makeaway.fish | 26 ++++++++++++++++++++++++++ Makefile | 1 + 2 files changed, 27 insertions(+) create mode 100644 .config/fish/functions/makeaway.fish diff --git a/.config/fish/functions/makeaway.fish b/.config/fish/functions/makeaway.fish new file mode 100644 index 0000000..c103f86 --- /dev/null +++ b/.config/fish/functions/makeaway.fish @@ -0,0 +1,26 @@ +function makeaway + # Check if no arguments were provided, or if the first argument is '--help' + if test -z $argv[1] || test "$argv[1]" = --help + echo -e "Usage: makeaway [-- ]" + echo -e " makeaway --help \t\t - Show this help message" + echo -e " makeaway \t\t - Run 'make' in the specified directory" + echo -e " makeaway -- - Run 'make ' in the specified directory" + return 0 + end + + # Find the target + set target "" + if test (count $argv) -ge 3 && test "$argv[2]" = -- + # Target required + set target $argv[3] + else if test (count $argv) -ge 2 && test "$argv[2]" = -- + # User used "--" without target + echo "No target found." + return 1 + end + + # Make + cd $argv[1] + make $target + cd - +end diff --git a/Makefile b/Makefile index 69df5a3..ff5c6db 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ sync-dotconfig: @mkdir -p $(HOME)/.config/fish/functions @$(WGET) $(REPO_SRC)/.config/fish/functions/fish_prompt.fish -O $(HOME)/.config/fish/functions/fish_prompt.fish + @$(WGET) $(REPO_SRC)/.config/fish/functions/makeaway.fish -O $(HOME)/.config/fish/functions/makeaway.fish @$(WGET) $(REPO_SRC)/.config/fish/conf.d/abbr.fish -O $(HOME)/.config/fish/conf.d/abbr.fish @$(WGET) $(REPO_SRC)/.config/fish/conf.d/alias.fish -O $(HOME)/.config/fish/conf.d/alias.fish