configure bat
This commit is contained in:
parent
f9f0e9b9c7
commit
64325631a6
3 changed files with 114 additions and 34 deletions
|
|
@ -31,8 +31,10 @@
|
||||||
ntv = "nix-search-tv";
|
ntv = "nix-search-tv";
|
||||||
rebuild = "nh os switch ~/flake";
|
rebuild = "nh os switch ~/flake";
|
||||||
trybuild = "nh os test ~/flake";
|
trybuild = "nh os test ~/flake";
|
||||||
brip = "batgrep"; # bat + ripgrep
|
|
||||||
man = "batman"; # bat + man
|
# shell utilities
|
||||||
|
rgf = "rg --files | rg";
|
||||||
|
watch = "viddy";
|
||||||
};
|
};
|
||||||
|
|
||||||
pointerCursor = {
|
pointerCursor = {
|
||||||
|
|
@ -45,14 +47,13 @@
|
||||||
|
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
# for services.gnome-keyring
|
# for services.gnome-keyring
|
||||||
pkgs.gcr # provides org.gnome.keyring.SystemPrompter
|
gcr # provides org.gnome.keyring.SystemPrompter
|
||||||
seahorse # gui
|
seahorse # gui
|
||||||
krita
|
|
||||||
|
|
||||||
|
krita
|
||||||
tor-browser
|
tor-browser
|
||||||
|
|
||||||
fuzzel
|
fuzzel
|
||||||
|
|
||||||
speedtest-cli
|
speedtest-cli
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,109 @@
|
||||||
{
|
let
|
||||||
config,
|
# Module Meta Configuration
|
||||||
pkgs,
|
setShellAliases = true;
|
||||||
...
|
supportBash = true;
|
||||||
}: {
|
supportZsh = true;
|
||||||
# like `/bin/cat` but with syntax highlighting
|
supportFish = true;
|
||||||
# TODO: change the pager (maybe use Github:sachaos/viddy instead)
|
in
|
||||||
programs.bat = {
|
{
|
||||||
enable = true;
|
osConfig,
|
||||||
config = {
|
config,
|
||||||
pager = "less -FR";
|
pkgs,
|
||||||
theme = "Dracula";
|
lib,
|
||||||
};
|
username,
|
||||||
};
|
...
|
||||||
|
}: let
|
||||||
|
inherit
|
||||||
|
(builtins)
|
||||||
|
elemAt
|
||||||
|
;
|
||||||
|
|
||||||
# other commands that make normal utils prettier
|
inherit
|
||||||
home.packages = with pkgs.bat-extras; [
|
(lib)
|
||||||
batdiff
|
flip
|
||||||
batgrep
|
mkIf
|
||||||
batman
|
optional
|
||||||
batwatch
|
splitString
|
||||||
prettybat
|
;
|
||||||
];
|
|
||||||
}
|
cfg = config.programs.bat;
|
||||||
|
|
||||||
|
# NOTE: `<derivation>.pname` can be used instead of `<derivation>.meta.mainProgram`
|
||||||
|
# NOTE: but then `pkgs.bash` would return `"bash-interactive"` which is annoying...
|
||||||
|
shellPkg = osConfig.users.users.${username}.shell;
|
||||||
|
shell = shellPkg.meta.mainProgram;
|
||||||
|
|
||||||
|
pager =
|
||||||
|
cfg.config.pager
|
||||||
|
|> splitString " "
|
||||||
|
|> flip elemAt 0;
|
||||||
|
in {
|
||||||
|
programs.bat = {
|
||||||
|
enable = true;
|
||||||
|
config = {
|
||||||
|
# WARNING: pager must be set for this module to function
|
||||||
|
# NOTE: not sure whether to use ov/moor/viddy as my pager?
|
||||||
|
pager = "less -FR";
|
||||||
|
# theme = "Dracula";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
home = {
|
||||||
|
shellAliases = mkIf setShellAliases {
|
||||||
|
bat = "prettybat";
|
||||||
|
cat = "prettybat";
|
||||||
|
diff = "batdiff";
|
||||||
|
brg = "batgrep";
|
||||||
|
man = "batman";
|
||||||
|
# watch = "batwatch"; # NOTE: using viddy instead atm
|
||||||
|
};
|
||||||
|
|
||||||
|
sessionVariables = {
|
||||||
|
PAGER = pager;
|
||||||
|
|
||||||
|
# REF: https://github.com/eth-p/bat-extras/blob/master/doc/batpipe.md
|
||||||
|
BATPIPE_ENABLE_COLOR = "true";
|
||||||
|
BATPIPE_INSIDE_LESS = "true";
|
||||||
|
BATPIPE_TERM_WIDTH = "-"; # hyphone -> auto detect
|
||||||
|
};
|
||||||
|
|
||||||
|
packages = with pkgs.bat-extras;
|
||||||
|
[
|
||||||
|
batdiff
|
||||||
|
batgrep
|
||||||
|
batman
|
||||||
|
batpipe
|
||||||
|
batwatch
|
||||||
|
prettybat
|
||||||
|
]
|
||||||
|
++ (with pkgs; [
|
||||||
|
bat
|
||||||
|
entr # required by pkgs.bat-extras.batwatch
|
||||||
|
ripgrep # required by pkgs.bat-extras.batgrep
|
||||||
|
delta # required by pkgs.bat-extras.batdiff
|
||||||
|
])
|
||||||
|
++ optional (pkgs?${pager}) pkgs.${pager};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Configure the user's shell to source batpipe
|
||||||
|
# WARNING: only currently supports bash, zsh, & fish
|
||||||
|
programs = {
|
||||||
|
bash = mkIf (supportBash || shell == "bash") {
|
||||||
|
initExtra = ''
|
||||||
|
eval "$(batpipe)"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
zsh = mkIf (supportZsh || shell == "zsh") {
|
||||||
|
initContent = ''
|
||||||
|
eval "$(batpipe)"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
fish = mkIf (supportFish || shell == "fish") {
|
||||||
|
interactiveShellInit = ''
|
||||||
|
eval (batpipe)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
config,
|
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
|
|
@ -60,9 +59,6 @@
|
||||||
curl -sL "https://www.gitignore.io/api/$type"
|
curl -sL "https://www.gitignore.io/api/$type"
|
||||||
end
|
end
|
||||||
|
|
||||||
# ripgrep on files
|
|
||||||
function rgf
|
|
||||||
rg --files | rg $args
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function decompile
|
function decompile
|
||||||
|
|
@ -70,8 +66,6 @@
|
||||||
end
|
end
|
||||||
|
|
||||||
set -g fish_greeting (rand_greet)
|
set -g fish_greeting (rand_greet)
|
||||||
|
|
||||||
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
shellAliases = {
|
shellAliases = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue