2024-04-12 08:45:28 +02:00
|
|
|
{ pkgs, ... }:
|
2024-02-05 11:46:52 +01:00
|
|
|
{
|
2024-04-12 08:45:28 +02:00
|
|
|
# Mark each prompt so you can jump between prompts with C-S-z and C-S-x
|
2022-12-23 09:16:29 +01:00
|
|
|
mark_prompt_start = {
|
|
|
|
onEvent = "fish_prompt";
|
|
|
|
body = ''
|
2024-04-12 08:45:28 +02:00
|
|
|
${pkgs.coreutils}/bin/echo -en "\e]133;A\e\\"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
# Mark the start and end of the output of a command
|
|
|
|
# This
|
|
|
|
foot_cmd_start = {
|
|
|
|
onEvent = "fish_preexec";
|
|
|
|
body = ''
|
|
|
|
${pkgs.coreutils}/bin/echo -en "\e]133;C\e\\"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
foot_cmd_end = {
|
|
|
|
onEvent = "fish_postexec";
|
|
|
|
body = ''
|
|
|
|
${pkgs.coreutils}/bin/echo -en "\e]133;D\e\\"
|
2022-12-23 09:16:29 +01:00
|
|
|
'';
|
|
|
|
};
|
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"
|
2024-04-12 08:45:28 +02:00
|
|
|
set files (${pkgs.git}/bin/git diff --diff-filter=ACMR --name-only $argv[1])
|
|
|
|
set repo_path (${pkgs.coreutils}/bin/realpath --relative-to=$PWD (${pkgs.git}/bin/git rev-parse --show-toplevel))
|
|
|
|
set clangformat (${pkgs.git}/bin/git config --get clangFormat.binary)
|
|
|
|
${pkgs.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
|
2024-04-12 08:45:28 +02:00
|
|
|
set file (${pkgs.coreutils}/bin/realpath $repo_path/$f)
|
|
|
|
${pkgs.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
|
2024-04-12 08:45:28 +02:00
|
|
|
${pkgs.coreutils}/bin/echo "Formatting $file"
|
2022-03-01 20:06:19 +01:00
|
|
|
$clangformat -i -style=file $file
|
|
|
|
else
|
2024-04-12 08:45:28 +02:00
|
|
|
${pkgs.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
|
|
|
|
2024-04-12 08:45:28 +02:00
|
|
|
kink = {
|
|
|
|
body = ''
|
|
|
|
set -f pls_url = "https://playerservices.streamtheworld.com/pls/KINKAAC.pls"
|
|
|
|
if [ "$channel" = "dna" ]
|
|
|
|
set pls_url "https://playerservices.streamtheworld.com/pls/KINK_DNAAAC.pls"
|
|
|
|
else if [ "$channel" = "distortion" ]
|
|
|
|
set pls_url "https://playerservices.streamtheworld.com/pls/KINK_DISTORTIONAAC.pls"
|
|
|
|
end
|
|
|
|
set -f stream_url (${pkgs.curl}/bin/curl -sSL $pls_url | grep File | shuf | head -n 1 | awk -F '=' 'BEGIN { RS="\r\n" } { print $2 }')
|
|
|
|
mpc clear
|
|
|
|
mpc add "$stream_url"
|
|
|
|
mpc play
|
|
|
|
'';
|
|
|
|
argumentNames = "channel";
|
|
|
|
description = "Play a KINK channel with mpc";
|
|
|
|
};
|
|
|
|
|
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
|
2024-04-12 08:45:28 +02:00
|
|
|
${pkgs.coreutils}/bin/echo "$libname already exists"
|
2022-09-04 13:25:28 +02:00
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
|
|
|
if test -f $libmajor -o -L $libmajor
|
2024-04-12 08:45:28 +02:00
|
|
|
${pkgs.coreutils}/bin/echo "$libmajor already exists"
|
2022-09-04 13:25:28 +02:00
|
|
|
return 2
|
|
|
|
end
|
|
|
|
|
2024-04-12 08:45:28 +02:00
|
|
|
${pkgs.coreutils}/bin/ln -s $lib $libmajor
|
|
|
|
${pkgs.coreutils}/bin/ln -s $libmajor $libname
|
2022-09-04 13:25:28 +02:00
|
|
|
end
|
|
|
|
'';
|
|
|
|
};
|
2022-03-01 08:11:26 +01:00
|
|
|
}
|