add kak-pager and diffr

This commit is contained in:
Leonardo Eugênio 2022-08-05 21:09:52 -03:00
parent 9d850b5a09
commit 97bbd4ebb0
7 changed files with 114 additions and 6 deletions

13
diffr.nix Normal file
View file

@ -0,0 +1,13 @@
{ config, pkgs, lib, ... }:
pkgs.writeShellScriptBin "diffr" ''
exec ${pkgs.diffr}/bin/diffr \
--colors 'refine-added:foreground:green:underline' \
--colors 'refine-added:background:none' \
--colors 'refine-removed:foreground:red:underline' \
--colors 'refine-removed:background:none' \
--colors 'added:foreground:green' \
--colors 'added:background:none' \
--colors 'removed:foreground:red' \
--colors 'removed:background:none' \
$@
''

View file

@ -35,6 +35,8 @@
(_: _: { (_: _: {
dhist = dhist.packages.${system}.dhist; dhist = dhist.packages.${system}.dhist;
bmenu = import ./bmenu.nix { inherit config pkgs lib; }; bmenu = import ./bmenu.nix { inherit config pkgs lib; };
_diffr = import ./diffr.nix { inherit config pkgs lib; };
kak-pager = import ./kak-pager.nix { inherit config pkgs lib; };
}) })
]; ];
}) })

36
kak-pager.nix Normal file
View file

@ -0,0 +1,36 @@
{ config, pkgs, lib, ... }:
pkgs.writeScriptBin "kak-pager" ''
#!/usr/bin/env fish
if test (count $argv) -ne 0
for i in $argv
cat "$i"
end | eval (status filename)
exit 0
end
set term_line_count (tput lines)
while read line
set -a input_lines "$line"
set input_line_count (printf "%s\n" $input_lines | wc -l)
if test "$term_line_count" -lt "$input_line_count"
begin
printf "%s\n" $input_lines
cat
end | kak -e '
exec <a-o>
map global normal q :q<ret>;
rmhl global/number-lines;
set global scrolloff 10,0;
'
exit 0
end
end
printf "%s\n" $input_lines
''

34
user/git.nix Normal file
View file

@ -0,0 +1,34 @@
{ config, pkgs, lib, ... }:
let inherit (import ./variables.nix) username mail;
in {
config = {
programs.git = {
enable = true;
extraConfig = {
user = {
name = username;
email = mail.personal.user;
};
init.defaultBranch = "main";
commit.verbose = true;
pull.rebase = true;
merge.conflictStyle = "diff3";
rerere.enabled = true;
rebase = {
abbreviateCommands = true;
autoSquash = true;
autoStash = true;
};
pager = {
log = "${pkgs._diffr}/bin/diffr | ${pkgs.kak-pager}/bin/kak-pager";
show = "${pkgs._diffr}/bin/diffr | ${pkgs.kak-pager}/bin/kak-pager";
diff = "${pkgs._diffr}/bin/diffr | ${pkgs.kak-pager}/bin/kak-pager";
};
alias = {
graph = "log --graph --oneline --all";
root = "rev-parse --show-toplevel";
};
};
};
};
}

View file

@ -10,12 +10,7 @@ let
volumesh = volumesh =
pkgs.writeShellScriptBin "volumesh" (builtins.readFile ./scripts/volumesh); pkgs.writeShellScriptBin "volumesh" (builtins.readFile ./scripts/volumesh);
in { in {
imports = [ imports = [ ./waybar.nix ./helix.nix ./kakoune.nix ./sway.nix ./git.nix ];
./waybar.nix
./helix.nix
./kakoune.nix
./sway.nix
];
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
home.username = "lelgenio"; home.username = "lelgenio";
@ -35,6 +30,8 @@ in {
alacritty alacritty
exa exa
fd fd
_diffr
kak-pager
# text manipulation # text manipulation
sd sd
ripgrep ripgrep

View file

@ -125,6 +125,8 @@ in {
]; ];
home.sessionVariables = { home.sessionVariables = {
EDITOR = "kak"; EDITOR = "kak";
# Some plugins(kak_ansi) like to compile stuff
CC = "cc";
}; };
}; };
} }

View file

@ -66,4 +66,28 @@ in rec {
big = 16; big = 16;
}; };
}; };
username = "lelgenio";
mail = {
personal = {
from = "Leonardo Eugênio";
user = "lelgenio@disroot.org";
imap = "disroot.org";
smtp = "disroot.org";
pass = "disroot.org";
};
work = {
from = "Leonardo Eugênio";
user = "leonardo@wopus.com.br";
imap = "imap.wopus.com.br";
smtp = "smtp.wopus.com.br";
pass = "Work/wopus_email";
};
};
nextcloud = {
name = "disroot";
user = "lelgenio";
host = "cloud.disroot.org";
pass = "disroot.org";
};
} }