Update fish prompt and add to root user
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
{
|
{
|
||||||
home-manager.users.me = import ./home/common.nix;
|
home-manager.users.me = import ./home/common.nix;
|
||||||
home-manager.extraSpecialArgs = { inherit inputs; };
|
home-manager.extraSpecialArgs = { inherit inputs; };
|
||||||
|
home-manager.users.root = import ./home/root.nix;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
in {
|
in {
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ function postexec_test --on-event fish_postexec
|
|||||||
echo
|
echo
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set -g fish_prompt_pwd_dir_length 0
|
||||||
|
|
||||||
function fish_prompt
|
function fish_prompt
|
||||||
set -l last_status $status
|
set -l last_status $status
|
||||||
set -l markers
|
set -l markers
|
||||||
@@ -53,20 +55,93 @@ function fish_prompt
|
|||||||
set_color 9ece6a
|
set_color 9ece6a
|
||||||
echo -n "$host "
|
echo -n "$host "
|
||||||
|
|
||||||
set_color 89ddff
|
set -l pwd
|
||||||
echo -n (prompt_pwd)
|
|
||||||
|
|
||||||
set_color bb9af7
|
if git rev-parse --show-toplevel >/dev/null 2>&1
|
||||||
echo -n (fish_git_prompt)
|
set -l root (git rev-parse --show-toplevel)
|
||||||
|
set -l rel (string replace "$root/" "" "$PWD")
|
||||||
|
set pwd (basename "$root")
|
||||||
|
if test "$rel" = "$PWD"
|
||||||
|
set pwd (basename "$root")
|
||||||
|
else
|
||||||
|
set pwd (basename "$root")"/"$rel
|
||||||
|
end
|
||||||
|
else
|
||||||
|
set pwd (prompt_pwd)
|
||||||
|
end
|
||||||
|
|
||||||
|
set_color 89ddff
|
||||||
|
echo -n $pwd
|
||||||
|
|
||||||
|
set -l git_info (git status --porcelain=v2 --branch 2>/dev/null)
|
||||||
|
|
||||||
|
if test $status -eq 0
|
||||||
|
set -l branch
|
||||||
|
set -l ahead 0
|
||||||
|
set -l behind 0
|
||||||
|
set -l staged 0
|
||||||
|
set -l modified 0
|
||||||
|
set -l untracked 0
|
||||||
|
|
||||||
|
for line in $git_info
|
||||||
|
switch $line
|
||||||
|
case '# branch.head*'
|
||||||
|
set branch (string split ' ' $line)[3]
|
||||||
|
|
||||||
|
case '# branch.ab*'
|
||||||
|
set -l parts (string split ' ' $line)
|
||||||
|
set ahead (string sub -s 2 -- $parts[3])
|
||||||
|
set behind (string sub -s 2 -- $parts[4])
|
||||||
|
|
||||||
|
case '1*' '2*'
|
||||||
|
set -l xy (string sub -s 3 -l 2 $line)
|
||||||
|
if test (string sub -s 1 -l 1 $xy) != "."
|
||||||
|
set staged (math $staged + 1)
|
||||||
|
end
|
||||||
|
if test (string sub -s 2 -l 1 $xy) != "."
|
||||||
|
set modified (math $modified + 1)
|
||||||
|
end
|
||||||
|
case '?*'
|
||||||
|
set untracked (math $untracked + 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
set_color bb9af7
|
||||||
|
echo -n " [$branch"
|
||||||
|
|
||||||
|
test $ahead -gt 0; and echo -n " ↑$ahead"
|
||||||
|
test $behind -gt 0; and echo -n " ↓$behind"
|
||||||
|
test $staged -gt 0; and echo -n " +$staged"
|
||||||
|
test $modified -gt 0; and echo -n " ~$modified"
|
||||||
|
test $untracked -gt 0; and echo -n " ?$untracked"
|
||||||
|
|
||||||
|
echo -n "]"
|
||||||
|
end
|
||||||
|
|
||||||
if test (count $markers) -gt 0
|
if test (count $markers) -gt 0
|
||||||
set_color ff9e64
|
set_color ff9e64
|
||||||
echo -n " ("(string join " " $markers)")"
|
echo -n " ("(string join " " $markers)")"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set_color white
|
||||||
|
|
||||||
|
if test (count (jobs)) -gt 0
|
||||||
|
echo -n " "(count (jobs))
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q SSH_CONNECTION
|
||||||
|
echo -n " on ssh"
|
||||||
|
end
|
||||||
|
|
||||||
echo
|
echo
|
||||||
set_color 73daca
|
|
||||||
echo -n "λ "
|
if fish_is_root_user
|
||||||
|
set_color ff007c
|
||||||
|
echo -n "# "
|
||||||
|
else
|
||||||
|
set_color 73daca
|
||||||
|
echo -n "λ "
|
||||||
|
end
|
||||||
|
|
||||||
set_color normal
|
set_color normal
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./fish
|
||||||
|
./eza
|
||||||
|
];
|
||||||
|
|
||||||
|
home.username = "root";
|
||||||
|
home.homeDirectory = "/root";
|
||||||
|
|
||||||
|
home.stateVersion = "26.05";
|
||||||
|
}
|
||||||
@@ -34,6 +34,8 @@
|
|||||||
useXkbConfig = true;
|
useXkbConfig = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
users.users.root.shell = pkgs.fish;
|
||||||
|
|
||||||
users.users.me = {
|
users.users.me = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
shell = pkgs.fish;
|
shell = pkgs.fish;
|
||||||
@@ -53,6 +55,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
|
neovim
|
||||||
|
gitui
|
||||||
libinput
|
libinput
|
||||||
gnupg
|
gnupg
|
||||||
age
|
age
|
||||||
|
|||||||
Reference in New Issue
Block a user