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
This commit is contained in:
Erwin Boskma 2022-12-23 09:16:29 +01:00
parent eec99400a3
commit 8ab255b66a
Signed by: erwin
SSH key fingerprint: SHA256:CyeNoWXd3kjX2Nwu6pDxxdS7OqmPVOy0NavA/KU/ntU
2 changed files with 17 additions and 11 deletions

View file

@ -14,7 +14,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.fish = { programs.fish = {
enable = true; enable = true;
functions = import ./functions.nix { inherit (pkgs) git; }; functions = import ./functions.nix { inherit (pkgs) git coreutils; };
plugins = [ plugins = [
{ {

View file

@ -1,4 +1,10 @@
{ git }: { { git, coreutils }: {
mark_prompt_start = {
onEvent = "fish_prompt";
body = ''
${coreutils}/bin/echo -en "\e]133;A\e\\"
'';
};
reload = { reload = {
body = '' body = ''
history --save history --save
@ -22,19 +28,19 @@
set files (${git}/bin/git diff --diff-filter=ACMR --name-only $argv[1]) 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 repo_path (realpath --relative-to=$PWD (${git}/bin/git rev-parse --show-toplevel))
set clangformat (${git}/bin/git config --get clangFormat.binary) 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 for f in $files
set file (realpath $repo_path/$f) set file (realpath $repo_path/$f)
echo "Processing $file" ${coreutils}/bin/echo "Processing $file"
set ext (string match -r ".*\.([^\.]+)\$" $file)[2] set ext (string match -r ".*\.([^\.]+)\$" $file)[2]
if contains $ext $source_exts if contains $ext $source_exts
echo "Formatting $file" ${coreutils}/bin/echo "Formatting $file"
$clangformat -i -style=file $file $clangformat -i -style=file $file
else else
echo "Extension $ext not found in $source_exts" ${coreutils}/bin/echo "Extension $ext not found in $source_exts"
end end
end end
''; '';
@ -49,17 +55,17 @@
set libmajor $libname.$libcomponents[3] set libmajor $libname.$libcomponents[3]
if test -f $libname -o -L $libname if test -f $libname -o -L $libname
echo "$libname already exists" ${coreutils}/bin/echo "$libname already exists"
return 1 return 1
end end
if test -f $libmajor -o -L $libmajor if test -f $libmajor -o -L $libmajor
echo "$libmajor already exists" ${coreutils}/bin/echo "$libmajor already exists"
return 2 return 2
end end
ln -s $lib $libmajor ${coreutils}/bin/ln -s $lib $libmajor
ln -s $libmajor $libname ${coreutils}/bin/ln -s $libmajor $libname
end end
''; '';
}; };