2024-08-02 11:12:36 +02:00
|
|
|
|
{ lib, pkgs, ... }:
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
programs.fish = {
|
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
|
|
plugins = [
|
|
|
|
|
{
|
2024-08-21 10:12:03 +02:00
|
|
|
|
name = "grc";
|
|
|
|
|
src = pkgs.fishPlugins.grc.src;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
name = "transient";
|
|
|
|
|
src = pkgs.fishPlugins.transient-fish.src;
|
2024-08-02 11:12:36 +02:00
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
functions = {
|
2024-09-14 10:32:23 +02:00
|
|
|
|
tmux-refresh-env = {
|
|
|
|
|
description = "Refresh environment variables from tmux session";
|
|
|
|
|
body = ''
|
|
|
|
|
for var in (tmux show-environment | string match -rv '^-')
|
|
|
|
|
set -l parts (string split -m 1 '=' $var)
|
|
|
|
|
if test (count $parts) -eq 2
|
|
|
|
|
set -Ux $parts[1] $parts[2]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-21 10:12:03 +02:00
|
|
|
|
kubectl = {
|
|
|
|
|
description = "Wraps kubectl in grc";
|
|
|
|
|
wraps = "kubectl";
|
|
|
|
|
body = "grc.wrap kubectl $argv";
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-02 11:12:36 +02:00
|
|
|
|
edit = {
|
|
|
|
|
description = "Open a file in already running nvim and switch tab";
|
|
|
|
|
argumentNames = [ "file" ];
|
|
|
|
|
body = ''
|
|
|
|
|
set _file (readlink -f "$file")
|
|
|
|
|
if test -z "$file"
|
|
|
|
|
set _root (vcs_root)
|
|
|
|
|
set _file (fd --type f . "$_root" | sed -e "s#^$_root/##" | fzf --no-sort --layout=reverse)
|
|
|
|
|
set _file "$_root/$_file"
|
|
|
|
|
end
|
2024-08-12 13:11:20 +02:00
|
|
|
|
set _nvim_socket "$XDG_RUNTIME_DIR/nvim-persistent.sock"
|
|
|
|
|
if test -S "$_nvim_socket" && tmux select-window -t nvim 2>/dev/null
|
|
|
|
|
nvim --server "$_nvim_socket" --remote "$_file"
|
|
|
|
|
return 0
|
|
|
|
|
end
|
|
|
|
|
tmux new-window -S -n nvim nvim --listen "$_nvim_socket" "$_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 = ''
|
|
|
|
|
# Is jj installed?
|
|
|
|
|
if not command -sq jj
|
|
|
|
|
return 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Are we in a jj repo?
|
|
|
|
|
if not jj root --quiet &>/dev/null
|
|
|
|
|
return 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Generate prompt
|
|
|
|
|
jj log --ignore-working-copy --no-graph --color always -r @ -T '
|
|
|
|
|
separate(
|
|
|
|
|
" ",
|
|
|
|
|
change_id.shortest(),
|
|
|
|
|
coalesce(
|
|
|
|
|
surround(
|
|
|
|
|
"\"",
|
|
|
|
|
"\"",
|
|
|
|
|
if(
|
|
|
|
|
description.first_line().substr(0, 24).starts_with(description.first_line()),
|
|
|
|
|
description.first_line().substr(0, 24),
|
|
|
|
|
description.first_line().substr(0, 23) ++ "…"
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
"(no description set)"
|
|
|
|
|
),
|
2024-10-06 22:08:36 +02:00
|
|
|
|
bookmarks.join(", "),
|
2024-08-02 11:12:36 +02:00
|
|
|
|
commit_id.shortest(),
|
|
|
|
|
if(conflict, "(conflict)"),
|
|
|
|
|
if(empty, "(empty)"),
|
|
|
|
|
if(divergent, "(divergent)"),
|
|
|
|
|
if(hidden, "(hidden)"),
|
|
|
|
|
)
|
|
|
|
|
'
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
fish_prompt.body = ''
|
|
|
|
|
echo
|
2024-08-27 16:12:53 +02:00
|
|
|
|
string join "" -- (set_color --italics) (prompt_hostname) ':' (prompt_pwd --full-length-dirs=4) (set_color yellow) ' ❯ ' (set_color normal)
|
2024-08-02 11:12:36 +02:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
fish_right_prompt.body = ''
|
|
|
|
|
fish_jj_prompt || fish_vcs_prompt
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
transient_prompt_func.body = ''
|
|
|
|
|
echo
|
2024-08-27 16:12:53 +02:00
|
|
|
|
string join "" -- (set_color yellow) '❯ ' (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/go-task.fish)
|
|
|
|
|
(builtins.readFile ../../files/config/fish/jj.fish)
|
|
|
|
|
(builtins.readFile ../../files/config/fish/vcs.fish)
|
2024-08-02 11:12:36 +02:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
shellAbbrs = {
|
|
|
|
|
e = "edit";
|
|
|
|
|
l = "bat";
|
|
|
|
|
ls = "eza";
|
|
|
|
|
tree = "eza --tree";
|
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'";
|
|
|
|
|
w = "viddy -n1 $history[1]";
|
|
|
|
|
xc = "fish_clipboard_copy";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|