ref: git lola and git lol as git plugins for ease of shipping

telescope-reuse-window
htran 2023-09-30 21:49:13 -07:00
parent 75ba98e276
commit 2dd2ae2c08
4 changed files with 60 additions and 72 deletions

View File

@ -20,8 +20,8 @@ in {
c = "commit"; c = "commit";
ca = "commit --amend"; ca = "commit --amend";
cm = "commit -m"; cm = "commit -m";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit"; # lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all"; # lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts = "status"; sts = "status";
co = "checkout"; co = "checkout";
b = "branch"; b = "branch";

View File

@ -151,11 +151,26 @@ in {
''; '';
example = [".direnv" "node_modules"]; example = [".direnv" "node_modules"];
}; };
plugins = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [
cell.packages.git-plus
];
description = ''
Git plugins are just programs that are exposed to git-custom-command.
Git takes the responsibility to do map it into `git custom-command`
'';
example = ''
[ pkgs.git-filter-repo ]
'';
};
}; };
# WARNING: This should be completed wtf config = {
config."${namespace}".git = { "${namespace}".git = {
inherit (cfg) name email ignores aliases; inherit (cfg) name email ignores aliases;
enable = true; enable = true;
};
home.packages = cfg.plugins;
}; };
}; };

View File

@ -89,40 +89,7 @@ in {
enableCompletion = true; enableCompletion = true;
initExtra = cfg.shellInitExtra or ""; initExtra = cfg.shellInitExtra or "";
shellAliases = shellAliases =
{ { }
git-lol = ''
git log --graph --decorate --color=always --abbrev-commit \
--pretty=format:'%C(auto)%h %d %C(cyan)%s %C(green)(%cr)%C(reset)' |
while IFS= read -r line; do
# Format the relative time
line=$(echo "$line" | sed -e 's/ minute/ min/' \
-e 's/ week/ wk/' \
-e 's/ hour/ hr/' \
-e 's/ month/ mo/' \
-e 's/ year/ yr/' \
-e 's/ ago//')
# Print the formatted line
echo "$line"
done | less -R
'';
git-lola = ''
git log --graph --decorate --color=always --abbrev-commit --all\
--pretty=format:'%C(auto)%h %d %C(cyan)%s %C(green)(%cr)%C(reset)' |
while IFS= read -r line; do
# Format the relative time
line=$(echo "$line" | sed -e 's/ minute/ min/' \
-e 's/ week/ wk/' \
-e 's/ hour/ hr/' \
-e 's/ month/ mo/' \
-e 's/ year/ yr/' \
-e 's/ ago//')
# Print the formatted line
echo "$line"
done | less -R
'';
}
// (cfg.shellAliases or {}); // (cfg.shellAliases or {});
}; };
programs.zsh = { programs.zsh = {
@ -133,38 +100,6 @@ in {
{ {
nix-rebuild = "sudo nixos-rebuild switch"; nix-rebuild = "sudo nixos-rebuild switch";
hm-switch = "home-manager switch --flake"; hm-switch = "home-manager switch --flake";
git-lol = ''
git log --graph --decorate --color=always --abbrev-commit \
--pretty=format:'%C(auto)%h %d %C(cyan)%s %C(green)(%cr)%C(reset)' |
while IFS= read -r line; do
# Format the relative time
line=$(echo "$line" | sed -e 's/ minute/ min/' \
-e 's/ week/ wk/' \
-e 's/ hour/ hr/' \
-e 's/ month/ mo/' \
-e 's/ year/ yr/' \
-e 's/ ago//')
# Print the formatted line
echo "$line"
done | less -R
'';
git-lola = ''
git log --graph --decorate --color=always --abbrev-commit --all\
--pretty=format:'%C(auto)%h %d %C(cyan)%s %C(green)(%cr)%C(reset)' |
while IFS= read -r line; do
# Format the relative time
line=$(echo "$line" | sed -e 's/ minute/ min/' \
-e 's/ week/ wk/' \
-e 's/ hour/ hr/' \
-e 's/ month/ mo/' \
-e 's/ year/ yr/' \
-e 's/ ago//')
# Print the formatted line
echo "$line"
done | less -R
'';
} }
// (cfg.shellAliases or {}); // (cfg.shellAliases or {});
history = { history = {

View File

@ -41,4 +41,42 @@ in {
pixi-edit = inputs.cells.dev.packages.pixi-edit; pixi-edit = inputs.cells.dev.packages.pixi-edit;
nil = inputs.nixpkgs.nil; nil = inputs.nixpkgs.nil;
git-plus = pkgs.symlinkJoin {
name = "pegasust-git-plus";
paths = [
(pkgs.writeShellScriptBin "git-lola" ''
git log --graph --decorate --color=always --abbrev-commit --all\
--pretty=format:'%C(auto)%h %d %C(cyan)%s %C(green)(%cr)%C(reset)' |
while IFS= read -r line; do
# Format the relative time
line=$(echo "$line" | sed -e 's/ minute/ min/' \
-e 's/ week/ wk/' \
-e 's/ hour/ hr/' \
-e 's/ month/ mo/' \
-e 's/ year/ yr/' \
-e 's/ ago//')
# Print the formatted line
echo "$line"
done | less -R
'')
(pkgs.writeShellScriptBin "git-lol" ''
git log --graph --decorate --color=always --abbrev-commit \
--pretty=format:'%C(auto)%h %d %C(cyan)%s %C(green)(%cr)%C(reset)' |
while IFS= read -r line; do
# Format the relative time
line=$(echo "$line" | sed -e 's/ minute/ min/' \
-e 's/ week/ wk/' \
-e 's/ hour/ hr/' \
-e 's/ month/ mo/' \
-e 's/ year/ yr/' \
-e 's/ ago//')
# Print the formatted line
echo "$line"
done | less -R
'')
];
};
} }