From 8ab255b66a114c9f949f4c9f4497f637bd870d28 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Fri, 23 Dec 2022 09:16:29 +0100 Subject: [PATCH] Add mark_prompt_start function for fish It is for something foot uses, see https://codeberg.org/dnkl/foot/wiki#user-content-jumping-between-prompts for more info --- home-manager/modules/fish/default.nix | 2 +- home-manager/modules/fish/functions.nix | 26 +++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/home-manager/modules/fish/default.nix b/home-manager/modules/fish/default.nix index 250be48..74ae6e4 100644 --- a/home-manager/modules/fish/default.nix +++ b/home-manager/modules/fish/default.nix @@ -14,7 +14,7 @@ in config = mkIf cfg.enable { programs.fish = { enable = true; - functions = import ./functions.nix { inherit (pkgs) git; }; + functions = import ./functions.nix { inherit (pkgs) git coreutils; }; plugins = [ { diff --git a/home-manager/modules/fish/functions.nix b/home-manager/modules/fish/functions.nix index 6040906..19ae5ff 100644 --- a/home-manager/modules/fish/functions.nix +++ b/home-manager/modules/fish/functions.nix @@ -1,4 +1,10 @@ -{ git }: { +{ git, coreutils }: { + mark_prompt_start = { + onEvent = "fish_prompt"; + body = '' + ${coreutils}/bin/echo -en "\e]133;A\e\\" + ''; + }; reload = { body = '' history --save @@ -22,19 +28,19 @@ set files (${git}/bin/git diff --diff-filter=ACMR --name-only $argv[1]) set repo_path (realpath --relative-to=$PWD (${git}/bin/git rev-parse --show-toplevel)) set clangformat (${git}/bin/git config --get clangFormat.binary) - echo "Formatting files in $repo_path with $clangformat" + ${coreutils}/bin/echo "Formatting files in $repo_path with $clangformat" for f in $files set file (realpath $repo_path/$f) - echo "Processing $file" + ${coreutils}/bin/echo "Processing $file" set ext (string match -r ".*\.([^\.]+)\$" $file)[2] if contains $ext $source_exts - echo "Formatting $file" + ${coreutils}/bin/echo "Formatting $file" $clangformat -i -style=file $file else - echo "Extension $ext not found in $source_exts" + ${coreutils}/bin/echo "Extension $ext not found in $source_exts" end end ''; @@ -47,19 +53,19 @@ set libcomponents (string split "." "$lib") set libname $libcomponents[1].$libcomponents[2] set libmajor $libname.$libcomponents[3] - + if test -f $libname -o -L $libname - echo "$libname already exists" + ${coreutils}/bin/echo "$libname already exists" return 1 end if test -f $libmajor -o -L $libmajor - echo "$libmajor already exists" + ${coreutils}/bin/echo "$libmajor already exists" return 2 end - ln -s $lib $libmajor - ln -s $libmajor $libname + ${coreutils}/bin/ln -s $lib $libmajor + ${coreutils}/bin/ln -s $libmajor $libname end ''; };