2024-02-05 11:46:52 +01:00
|
|
|
{ git, coreutils }:
|
|
|
|
{
|
2022-12-23 09:16:29 +01:00
|
|
|
mark_prompt_start = {
|
|
|
|
onEvent = "fish_prompt";
|
|
|
|
body = ''
|
|
|
|
${coreutils}/bin/echo -en "\e]133;A\e\\"
|
|
|
|
'';
|
|
|
|
};
|
2022-03-01 08:11:26 +01:00
|
|
|
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 = ''
|
2022-03-01 20:06:19 +01:00
|
|
|
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)
|
2022-12-23 09:16:29 +01:00
|
|
|
${coreutils}/bin/echo "Formatting files in $repo_path with $clangformat"
|
2022-03-01 08:11:26 +01:00
|
|
|
|
2022-03-01 20:06:19 +01:00
|
|
|
for f in $files
|
|
|
|
set file (realpath $repo_path/$f)
|
2022-12-23 09:16:29 +01:00
|
|
|
${coreutils}/bin/echo "Processing $file"
|
2022-03-01 22:19:03 +01:00
|
|
|
|
2022-03-01 20:06:19 +01:00
|
|
|
set ext (string match -r ".*\.([^\.]+)\$" $file)[2]
|
2022-03-01 08:11:26 +01:00
|
|
|
|
2022-03-01 20:06:19 +01:00
|
|
|
if contains $ext $source_exts
|
2022-12-23 09:16:29 +01:00
|
|
|
${coreutils}/bin/echo "Formatting $file"
|
2022-03-01 20:06:19 +01:00
|
|
|
$clangformat -i -style=file $file
|
|
|
|
else
|
2022-12-23 09:16:29 +01:00
|
|
|
${coreutils}/bin/echo "Extension $ext not found in $source_exts"
|
2022-03-01 08:11:26 +01:00
|
|
|
end
|
2022-03-01 20:06:19 +01:00
|
|
|
end
|
2022-03-01 08:11:26 +01:00
|
|
|
'';
|
|
|
|
description = "Use clang-format to format all changed and added files";
|
|
|
|
};
|
2022-09-04 13:25:28 +02:00
|
|
|
|
|
|
|
linklib = {
|
|
|
|
body = ''
|
|
|
|
function linklib --argument lib
|
|
|
|
set libcomponents (string split "." "$lib")
|
|
|
|
set libname $libcomponents[1].$libcomponents[2]
|
|
|
|
set libmajor $libname.$libcomponents[3]
|
2022-12-23 09:16:29 +01:00
|
|
|
|
2022-09-04 13:25:28 +02:00
|
|
|
if test -f $libname -o -L $libname
|
2022-12-23 09:16:29 +01:00
|
|
|
${coreutils}/bin/echo "$libname already exists"
|
2022-09-04 13:25:28 +02:00
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
|
|
|
if test -f $libmajor -o -L $libmajor
|
2022-12-23 09:16:29 +01:00
|
|
|
${coreutils}/bin/echo "$libmajor already exists"
|
2022-09-04 13:25:28 +02:00
|
|
|
return 2
|
|
|
|
end
|
|
|
|
|
2022-12-23 09:16:29 +01:00
|
|
|
${coreutils}/bin/ln -s $lib $libmajor
|
|
|
|
${coreutils}/bin/ln -s $libmajor $libname
|
2022-09-04 13:25:28 +02:00
|
|
|
end
|
|
|
|
'';
|
|
|
|
};
|
2022-03-01 08:11:26 +01:00
|
|
|
}
|