Erwin Boskma
8ab255b66a
It is for something foot uses, see https://codeberg.org/dnkl/foot/wiki#user-content-jumping-between-prompts for more info
72 lines
2.1 KiB
Nix
72 lines
2.1 KiB
Nix
{ git, coreutils }: {
|
|
mark_prompt_start = {
|
|
onEvent = "fish_prompt";
|
|
body = ''
|
|
${coreutils}/bin/echo -en "\e]133;A\e\\"
|
|
'';
|
|
};
|
|
reload = {
|
|
body = ''
|
|
history --save
|
|
set -gx dirprev $dirprev
|
|
set -gx dirnext $dirnext
|
|
set -gx dirstack $dirstack
|
|
set -g fish_greeting ""
|
|
exec fish
|
|
'';
|
|
description = "Reload Fish while keeping some context";
|
|
};
|
|
update-env = {
|
|
body = ''
|
|
set -gx SWAYSOCK /run/user/(id -u)/sway-ipc.(id -u).(pgrep -x sway).sock
|
|
'';
|
|
description = "Update environment variables";
|
|
};
|
|
clangfmt = {
|
|
body = ''
|
|
set source_exts "h" "hpp" "c" "cpp" "cc" "cp" "c++" "cxx" "cu" "proto"
|
|
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)
|
|
${coreutils}/bin/echo "Formatting files in $repo_path with $clangformat"
|
|
|
|
for f in $files
|
|
set file (realpath $repo_path/$f)
|
|
${coreutils}/bin/echo "Processing $file"
|
|
|
|
set ext (string match -r ".*\.([^\.]+)\$" $file)[2]
|
|
|
|
if contains $ext $source_exts
|
|
${coreutils}/bin/echo "Formatting $file"
|
|
$clangformat -i -style=file $file
|
|
else
|
|
${coreutils}/bin/echo "Extension $ext not found in $source_exts"
|
|
end
|
|
end
|
|
'';
|
|
description = "Use clang-format to format all changed and added files";
|
|
};
|
|
|
|
linklib = {
|
|
body = ''
|
|
function linklib --argument lib
|
|
set libcomponents (string split "." "$lib")
|
|
set libname $libcomponents[1].$libcomponents[2]
|
|
set libmajor $libname.$libcomponents[3]
|
|
|
|
if test -f $libname -o -L $libname
|
|
${coreutils}/bin/echo "$libname already exists"
|
|
return 1
|
|
end
|
|
|
|
if test -f $libmajor -o -L $libmajor
|
|
${coreutils}/bin/echo "$libmajor already exists"
|
|
return 2
|
|
end
|
|
|
|
${coreutils}/bin/ln -s $lib $libmajor
|
|
${coreutils}/bin/ln -s $libmajor $libname
|
|
end
|
|
'';
|
|
};
|
|
}
|