nixos-config/modules/cli/powerline.nix

58 lines
1.4 KiB
Nix
Raw Normal View History

2023-12-21 06:38:32 +00:00
{ pkgs, ... }:
2021-10-11 17:08:18 +00:00
let
2023-09-06 02:35:03 +00:00
left_hard_divider = builtins.fromJSON '' "\uE0B0" '';
upper_left_triangle = builtins.fromJSON '' "\uE0BC" '';
2023-06-14 07:25:10 +00:00
theme = {
BoldForeground = true;
2023-06-23 20:18:03 +00:00
CwdFg = 231;
2023-06-14 07:25:10 +00:00
PathBg = 24;
2023-06-23 20:18:03 +00:00
PathFg = 231;
2023-06-14 07:25:10 +00:00
SeparatorFg = 16;
};
2023-06-15 14:28:41 +00:00
customEnd = [{
Content = "$";
2023-06-23 20:18:03 +00:00
Foreground = 231;
Background = 102;
2023-09-06 02:35:03 +00:00
Separator = left_hard_divider;
2023-06-15 14:28:41 +00:00
}];
plconfig = builtins.toFile "powerline-config.json" (builtins.toJSON {
2023-09-06 02:35:03 +00:00
modes.patched.Separator = upper_left_triangle;
2023-06-15 14:28:41 +00:00
});
2023-06-05 18:42:32 +00:00
args = [
2023-06-15 14:28:41 +00:00
"-modules=\${remote:+'user,host,'}nix-shell,git,jobs,cwd,newline,customend"
2023-06-05 18:42:32 +00:00
"-git-assume-unchanged-size 0"
2023-06-14 07:23:52 +00:00
"-theme /etc/powerline-theme.json"
2023-06-05 18:42:32 +00:00
"-path-aliases '~/git=~/git'"
"-jobs $(jobs -p | wc -l)"
2023-06-05 18:42:32 +00:00
];
2024-06-22 17:12:18 +00:00
termtitle = ''\[\e]0;\u@\h: \w\a\]'';
2021-10-11 17:08:18 +00:00
in
{
2023-06-15 14:28:41 +00:00
environment.systemPackages = [
pkgs.powerline-go
(pkgs.writeShellScriptBin
"powerline-go-customend"
"echo '${builtins.toJSON customEnd}'")
];
2021-10-11 17:08:18 +00:00
2023-06-14 07:23:52 +00:00
environment.etc."powerline-theme.json".text = builtins.toJSON theme;
2023-06-05 18:42:32 +00:00
programs.bash.interactiveShellInit = ''
2023-06-15 14:28:41 +00:00
install -D ${plconfig} ~/.config/powerline-go/config.json
2023-06-05 18:42:32 +00:00
function _update_ps1() {
local remote=y
[ "$XDG_SESSION_TYPE" = "x11" ] && unset remote
[ "$XDG_SESSION_TYPE" = "wayland" ] && unset remote
2024-06-22 17:12:18 +00:00
PS1="${termtitle}$(powerline-go ${toString args})"
2023-06-05 18:42:32 +00:00
}
[ "$TERM" = "linux" ] || PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
'';
2021-10-11 17:08:18 +00:00
}