2024-08-02 11:12:36 +02:00
|
|
|
|
{ lib, pkgs, ... }:
|
|
|
|
|
{
|
|
|
|
|
programs.fish = {
|
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
|
|
plugins = [
|
2024-08-21 10:12:03 +02:00
|
|
|
|
{
|
|
|
|
|
name = "transient";
|
|
|
|
|
src = pkgs.fishPlugins.transient-fish.src;
|
2024-08-02 11:12:36 +02:00
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
functions = {
|
2024-10-12 13:24:53 +02:00
|
|
|
|
confirm = {
|
|
|
|
|
description = "Ask for confirmation";
|
|
|
|
|
argumentNames = [ "message" ];
|
|
|
|
|
body = ''
|
|
|
|
|
read -l -p 'printf "\\e[31;1m$message\\e[0m (y/N) "' confirm
|
|
|
|
|
test "$confirm" = 'y'
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
poweroff = {
|
|
|
|
|
description = "Wraps poweroff to first prompt for confirmation";
|
|
|
|
|
wraps = "poweroff";
|
|
|
|
|
body = ''confirm "⚠ Really poweroff $(hostname)?" && command poweroff $argv'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reboot = {
|
|
|
|
|
description = "Wraps reboot to first prompt for confirmation";
|
|
|
|
|
wraps = "reboot";
|
|
|
|
|
body = ''confirm "⚠ Really reboot $(hostname)?" && command reboot $argv'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
shutdown = {
|
|
|
|
|
description = "Wraps shutdown to first prompt for confirmation";
|
|
|
|
|
wraps = "shutdown";
|
|
|
|
|
body = ''confirm "⚠ Really shutdown $(hostname)?" && command shutdown $argv'';
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-01 13:12:48 +01:00
|
|
|
|
e = {
|
|
|
|
|
description = "Open a file in already running nvim";
|
2024-08-02 11:12:36 +02:00
|
|
|
|
argumentNames = [ "file" ];
|
|
|
|
|
body = ''
|
2025-01-02 10:55:43 +01:00
|
|
|
|
nvim-remote --remote (readlink -f "$file")
|
2024-08-02 11:12:36 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-10 16:11:50 +02:00
|
|
|
|
jl.body = ''
|
|
|
|
|
jj log --color=always --no-graph -T builtin_log_oneline -r 'all()' | fzf --ansi --reverse --wrap --preview 'jj show --tool=difftu {1}' --preview-window=down,70% --color=light
|
|
|
|
|
'';
|
|
|
|
|
|
2024-08-02 11:12:36 +02:00
|
|
|
|
__zoxide_zi_repaint.body = ''
|
|
|
|
|
__zoxide_zi
|
|
|
|
|
commandline -f repaint
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
fish_jj_prompt.body = ''
|
2025-01-13 18:40:36 +01:00
|
|
|
|
if not command -sq jj || not jj root --quiet &>/dev/null
|
|
|
|
|
return 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
jj log --ignore-working-copy --no-graph --color never -r @ -T '
|
|
|
|
|
surround(
|
|
|
|
|
" \e[2;3m",
|
|
|
|
|
"\e[0m",
|
|
|
|
|
separate(
|
|
|
|
|
" ",
|
|
|
|
|
surround(
|
|
|
|
|
"\e[0;2;3m",
|
|
|
|
|
"\e[0m",
|
|
|
|
|
coalesce(
|
|
|
|
|
surround(
|
|
|
|
|
"\e[1;2;3m❝",
|
|
|
|
|
"❞\e[0m",
|
|
|
|
|
if(
|
|
|
|
|
description.first_line().substr(0, 80).starts_with(description.first_line()),
|
|
|
|
|
description.first_line().substr(0, 80),
|
|
|
|
|
description.first_line().substr(0, 79) ++ "…"
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
"…"
|
2024-11-21 13:50:07 +01:00
|
|
|
|
),
|
2024-11-19 16:48:04 +01:00
|
|
|
|
),
|
2025-01-13 18:40:36 +01:00
|
|
|
|
surround("\e[0;1;95m ", "\e[0;2;3m", change_id.shortest()),
|
|
|
|
|
surround("\e[0;35m ", "\e[0m", bookmarks.join("╱")),
|
|
|
|
|
surround("\e[0;34m ", "\e[0;2;3m", commit_id.shortest()),
|
|
|
|
|
if(conflict, ""),
|
|
|
|
|
if(empty, ""),
|
|
|
|
|
if(divergent, ""),
|
|
|
|
|
if(hidden, ""),
|
|
|
|
|
)
|
2024-11-19 16:48:04 +01:00
|
|
|
|
)
|
2025-01-13 18:40:36 +01:00
|
|
|
|
'
|
2024-08-02 11:12:36 +02:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
fish_prompt.body = ''
|
2024-11-21 13:50:07 +01:00
|
|
|
|
echo -e "\033[s\033[$LINES;1H\033[1;2;38;5;238m$(string pad -c '┄' -w $COLUMNS (fish_jj_prompt || fish_vcs_prompt))\033[0m\033[u"
|
2025-01-03 12:48:33 +01:00
|
|
|
|
string join "" -- (set_color --dim) (prompt_hostname) ':' (prompt_pwd --full-length-dirs=4) (set_color --bold normal) ' ❯ ' (set_color normal)
|
2024-08-02 11:12:36 +02:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
transient_prompt_func.body = ''
|
|
|
|
|
echo
|
2025-01-03 01:10:48 +01:00
|
|
|
|
string join "" -- (set_color --bold) '❯ ' (set_color normal)
|
2024-08-02 11:12:36 +02:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
rg.body = ''
|
|
|
|
|
if status is-interactive
|
2024-08-04 00:05:29 +02:00
|
|
|
|
command rg -p $argv --json | delta
|
2024-08-02 11:12:36 +02:00
|
|
|
|
else
|
|
|
|
|
command rg $argv
|
|
|
|
|
end
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
interactiveShellInit = lib.concatStringsSep "\n" [
|
2024-08-02 14:09:42 +02:00
|
|
|
|
(builtins.readFile ../../files/config/fish/config.fish)
|
|
|
|
|
(builtins.readFile ../../files/config/fish/semantic-prompt.fish)
|
|
|
|
|
(builtins.readFile ../../files/config/fish/vcs.fish)
|
2024-08-02 11:12:36 +02:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
shellAbbrs = {
|
|
|
|
|
l = "bat";
|
2024-08-21 09:57:34 +02:00
|
|
|
|
top = "btm --basic --enable_cache_memory --battery";
|
2024-08-02 11:12:36 +02:00
|
|
|
|
ts = "TZ=Z date '+%Y%m%dT%H%M%SZ'";
|
2024-11-24 19:18:53 +01:00
|
|
|
|
w = "viddy $history[1]";
|
2024-08-02 11:12:36 +02:00
|
|
|
|
xc = "fish_clipboard_copy";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|