flake/home/applications/fish/default.nix

104 lines
2.5 KiB
Nix
Raw Normal View History

2024-08-28 05:44:22 +08:00
{ lib, pkgs, ... }:
{
2023-11-05 17:21:37 +08:00
programs.fish = {
enable = true;
2024-08-28 05:44:22 +08:00
interactiveShellInit =
let
tide = pkgs.fishPlugins.tide.src + "/functions/tide/configure";
in
''
set fish_greeting
2024-09-16 13:07:58 +08:00
set fish_cursor_default block
set fish_cursor_insert line
set fish_cursor_replace_one underscore
set fish_cursor_replace underscore
set fish_cursor_external line
set fish_cursor_visual block
2024-09-16 13:07:58 +08:00
function fish_user_key_bindings
fish_default_key_bindings -M insert
fish_vi_key_bindings --no-erase insert
end
string replace -r '^' 'set -g ' < ${tide}/icons.fish | source
string replace -r '^' 'set -g ' < ${tide}/configs/lean.fish | source
string replace -r '^' 'set -g ' < ${tide}/configs/lean_16color.fish | source
'';
2024-08-28 05:44:22 +08:00
2024-09-21 01:33:24 +08:00
plugins =
lib.map
(f: {
name = f.pname;
inherit (f) src;
})
(
with pkgs.fishPlugins;
[
autopair
done
puffer
tide
2024-09-21 01:33:24 +08:00
]
);
shellAbbrs =
let
cursor = f: {
setCursor = true;
expansion = f;
};
in
2023-11-05 17:21:37 +08:00
{
2024-09-27 18:17:31 +08:00
gi = "lazygit";
2024-09-21 01:33:24 +08:00
p = "powerprofilesctl";
s = "nh os switch";
v = "nvim";
2024-10-13 00:10:05 +08:00
t = "tmux";
ta = "tmux attach";
2024-08-28 05:44:22 +08:00
2024-09-21 01:33:24 +08:00
# TODO: maybe fishPlugins.fish-git-abbr?
g = "git";
ga = "git add";
gac = cursor "git commit -am '%'";
gc = cursor "git commit -m '%'";
gca = "git commit --amend";
gd = "git diff";
gds = "git diff --staged";
gl = "git log";
gp = "git pull";
gpu = "git push";
gr = "git rebase -i --autosquash";
2024-09-16 13:30:23 +08:00
2024-09-21 01:33:24 +08:00
n = "nix";
nb = cursor "nix build nixpkgs#%";
nr = cursor "nix run nixpkgs#%";
ns = cursor "nix shell nixpkgs#%";
nbb = "nix-build -A";
nf = "nix fmt";
nu = "nix flake update";
nv = "nix eval";
};
2024-09-16 01:21:00 +08:00
2024-08-28 05:44:22 +08:00
functions =
let
jq = lib.getExe pkgs.jq;
nix = lib.getExe pkgs.nix;
curl = lib.getExe pkgs.curl;
in
{
"pb" = ''
${jq} -Rns '{text: inputs}' | \
${curl} -s -H 'Content-Type: application/json' --data-binary @- https://pb.ny4.dev | \
${jq} -r '. | "https://pb.ny4.dev\(.path)"'
'';
"getmnter" = ''
${nix} eval nixpkgs#{$argv}.meta.maintainers --json | \
${jq} '.[].github | "@" + .' -r
'';
};
2023-11-05 17:21:37 +08:00
};
}