fish: fix user config
Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
parent
66c36e9203
commit
111f7c947b
1 changed files with 109 additions and 117 deletions
|
@ -11,52 +11,12 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
# https://wiki.nixos.org/wiki/Fish
|
# https://wiki.nixos.org/wiki/Fish
|
||||||
# https://github.com/fish-shell/fish-shell
|
# https://github.com/fish-shell/fish-shell
|
||||||
programs.fish = {
|
programs.fish.enable = true;
|
||||||
enable = true;
|
|
||||||
|
|
||||||
promptInit = ''
|
|
||||||
# Disable greeting
|
|
||||||
set -g fish_greeting
|
|
||||||
|
|
||||||
# Prompt
|
|
||||||
function fish_prompt --description 'Write out the prompt'
|
|
||||||
set -l last_status $status
|
|
||||||
set -l normal (set_color normal)
|
|
||||||
set -l status_color (set_color brgreen)
|
|
||||||
set -l cwd_color (set_color $fish_color_cwd)
|
|
||||||
set -l vcs_color (set_color brpurple)
|
|
||||||
set -l prompt_status ""
|
|
||||||
|
|
||||||
# Since we display the prompt on a new line allow the directory names to be longer.
|
|
||||||
set -q fish_prompt_pwd_dir_length
|
|
||||||
or set -lx fish_prompt_pwd_dir_length 0
|
|
||||||
|
|
||||||
# Color the prompt differently when we're root
|
|
||||||
set -l suffix '❯'
|
|
||||||
if functions -q fish_is_root_user; and fish_is_root_user
|
|
||||||
if set -q fish_color_cwd_root
|
|
||||||
set cwd_color (set_color $fish_color_cwd_root)
|
|
||||||
end
|
|
||||||
set suffix '#'
|
|
||||||
end
|
|
||||||
|
|
||||||
# Color the prompt in red on error
|
|
||||||
if test $last_status -ne 0
|
|
||||||
set status_color (set_color $fish_color_error)
|
|
||||||
set prompt_status $status_color "[" $last_status "]" $normal
|
|
||||||
end
|
|
||||||
|
|
||||||
echo -s (prompt_login) ' ' $cwd_color (prompt_pwd) $vcs_color (fish_vcs_prompt) $normal ' ' $prompt_status
|
|
||||||
echo -n -s $status_color $suffix ' ' $normal
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
home-manager.users = {
|
home-manager.users = {
|
||||||
# Inherit root abbreviations from user
|
# Inherit root configuration from user
|
||||||
root.programs.fish = {
|
root.programs.fish = with config.home-manager.users.${config.custom.username}.programs.fish; {
|
||||||
enable = true;
|
inherit enable interactiveShellInit shellAbbrs;
|
||||||
shellAbbrs = config.home-manager.users.${config.custom.username}.programs.fish.shellAbbrs;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
${config.custom.username}.programs.fish = let
|
${config.custom.username}.programs.fish = let
|
||||||
|
@ -82,77 +42,77 @@ in {
|
||||||
"/r" = any "/run";
|
"/r" = any "/run";
|
||||||
"/rc" = any "/run/current-system";
|
"/rc" = any "/run/current-system";
|
||||||
|
|
||||||
jc = any "journalctl";
|
jc = "journalctl";
|
||||||
jcs = any "journalctl --system";
|
jcs = "journalctl --system";
|
||||||
jcse = any "journalctl --system --pager-end";
|
jcse = "journalctl --system --pager-end";
|
||||||
jcseu = any "journalctl --system --pager-end --unit";
|
jcseu = "journalctl --system --pager-end --unit";
|
||||||
jcsf = any "journalctl --system --follow";
|
jcsf = "journalctl --system --follow";
|
||||||
jcsfu = any "journalctl --system --follow --unit";
|
jcsfu = "journalctl --system --follow --unit";
|
||||||
jcsi = any "journalctl --system --identifier";
|
jcsi = "journalctl --system --identifier";
|
||||||
jcst = any "journalctl --system --target";
|
jcst = "journalctl --system --target";
|
||||||
jcsu = any "journalctl --system --unit";
|
jcsu = "journalctl --system --unit";
|
||||||
jcu = any "journalctl --user";
|
jcu = "journalctl --user";
|
||||||
jcue = any "journalctl --user --pager-end";
|
jcue = "journalctl --user --pager-end";
|
||||||
jcueu = any "journalctl --user --pager-end --unit";
|
jcueu = "journalctl --user --pager-end --unit";
|
||||||
jcuf = any "journalctl --user --follow";
|
jcuf = "journalctl --user --follow";
|
||||||
jcufu = any "journalctl --user --follow --unit";
|
jcufu = "journalctl --user --follow --unit";
|
||||||
jcui = any "journalctl --user --identifier";
|
jcui = "journalctl --user --identifier";
|
||||||
jcut = any "journalctl --user --target";
|
jcut = "journalctl --user --target";
|
||||||
jcuu = any "journalctl --user --unit";
|
jcuu = "journalctl --user --unit";
|
||||||
|
|
||||||
sc = any "systemctl";
|
sc = "systemctl";
|
||||||
scp = any "systemctl poweroff";
|
scp = "systemctl poweroff";
|
||||||
scr = any "systemctl reboot";
|
scr = "systemctl reboot";
|
||||||
scs = any "systemctl --system";
|
scs = "systemctl --system";
|
||||||
scsd = any "systemctl --system disable";
|
scsd = "systemctl --system disable";
|
||||||
scsdn = any "systemctl --system disable --now";
|
scsdn = "systemctl --system disable --now";
|
||||||
scse = any "systemctl --system reenable";
|
scse = "systemctl --system reenable";
|
||||||
scsen = any "systemctl --system reenable --now";
|
scsen = "systemctl --system reenable --now";
|
||||||
scsh = any "systemctl --system show";
|
scsh = "systemctl --system show";
|
||||||
scsl = any "systemctl --system list-unit-files";
|
scsl = "systemctl --system list-unit-files";
|
||||||
scsm = any "systemctl --system mask";
|
scsm = "systemctl --system mask";
|
||||||
scsr = any "systemctl --system restart";
|
scsr = "systemctl --system restart";
|
||||||
scsrr = any "systemctl --system reload-or-restart";
|
scsrr = "systemctl --system reload-or-restart";
|
||||||
scss = any "systemctl --system status";
|
scss = "systemctl --system status";
|
||||||
scst = any "systemctl --system stop";
|
scst = "systemctl --system stop";
|
||||||
scsu = any "systemctl --system unmask";
|
scsu = "systemctl --system unmask";
|
||||||
scu = any "systemctl --user";
|
scu = "systemctl --user";
|
||||||
scud = any "systemctl --user disable";
|
scud = "systemctl --user disable";
|
||||||
scudn = any "systemctl --user disable --now";
|
scudn = "systemctl --user disable --now";
|
||||||
scue = any "systemctl --user reenable";
|
scue = "systemctl --user reenable";
|
||||||
scuen = any "systemctl --user reenable --now";
|
scuen = "systemctl --user reenable --now";
|
||||||
scuh = any "systemctl --user show";
|
scuh = "systemctl --user show";
|
||||||
scul = any "systemctl --user list-unit-files";
|
scul = "systemctl --user list-unit-files";
|
||||||
scum = any "systemctl --user mask";
|
scum = "systemctl --user mask";
|
||||||
scur = any "systemctl --user restart";
|
scur = "systemctl --user restart";
|
||||||
scurr = any "systemctl --user reload-or-restart";
|
scurr = "systemctl --user reload-or-restart";
|
||||||
scus = any "systemctl --user status";
|
scus = "systemctl --user status";
|
||||||
scut = any "systemctl --user stop";
|
scut = "systemctl --user stop";
|
||||||
scuu = any "systemctl --user unmask";
|
scuu = "systemctl --user unmask";
|
||||||
|
|
||||||
d = any "docker";
|
d = "docker";
|
||||||
dc = any "docker compose";
|
dc = "docker compose";
|
||||||
dcd = any "docker compose down";
|
dcd = "docker compose down";
|
||||||
dce = any "docker compose exec";
|
dce = "docker compose exec";
|
||||||
dcl = any "docker compose logs";
|
dcl = "docker compose logs";
|
||||||
dcp = any "docker compose pull";
|
dcp = "docker compose pull";
|
||||||
dcu = any "docker compose up";
|
dcu = "docker compose up";
|
||||||
dcuf = any "docker compose up --force-recreate";
|
dcuf = "docker compose up --force-recreate";
|
||||||
de = any "docker exec";
|
de = "docker exec";
|
||||||
dei = any "docker exec --interactive";
|
dei = "docker exec --interactive";
|
||||||
deit = any "docker exec --interactive --tty";
|
deit = "docker exec --interactive --tty";
|
||||||
det = any "docker exec --tty";
|
det = "docker exec --tty";
|
||||||
di = any "docker images";
|
di = "docker images";
|
||||||
dk = any "docker kill";
|
dk = "docker kill";
|
||||||
dn = any "docker network";
|
dn = "docker network";
|
||||||
dnl = any "docker network ls";
|
dnl = "docker network ls";
|
||||||
dp = any "docker pull";
|
dp = "docker pull";
|
||||||
dps = any "docker ps";
|
dps = "docker ps";
|
||||||
dpsa = any "docker ps --all --size";
|
dpsa = "docker ps --all --size";
|
||||||
dr = any "docker rm";
|
dr = "docker rm";
|
||||||
ds = any "docker system";
|
ds = "docker system";
|
||||||
dsp = any "docker system prune";
|
dsp = "docker system prune";
|
||||||
dspav = any "docker system prune --all --volumes";
|
dspav = "docker system prune --all --volumes";
|
||||||
|
|
||||||
c = "clear";
|
c = "clear";
|
||||||
e = "exit";
|
e = "exit";
|
||||||
|
@ -202,6 +162,42 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
interactiveShellInit = ''
|
interactiveShellInit = ''
|
||||||
|
### Prompt
|
||||||
|
# Disable greeting
|
||||||
|
set -g fish_greeting
|
||||||
|
|
||||||
|
function fish_prompt --description 'Write out the prompt'
|
||||||
|
set -l last_status $status
|
||||||
|
set -l normal (set_color normal)
|
||||||
|
set -l status_color (set_color brgreen)
|
||||||
|
set -l cwd_color (set_color $fish_color_cwd)
|
||||||
|
set -l vcs_color (set_color brpurple)
|
||||||
|
set -l prompt_status ""
|
||||||
|
|
||||||
|
# Since we display the prompt on a new line allow the directory names to be longer.
|
||||||
|
set -q fish_prompt_pwd_dir_length
|
||||||
|
or set -lx fish_prompt_pwd_dir_length 0
|
||||||
|
|
||||||
|
# Color the prompt differently when we're root
|
||||||
|
set -l suffix '❯'
|
||||||
|
if functions -q fish_is_root_user; and fish_is_root_user
|
||||||
|
if set -q fish_color_cwd_root
|
||||||
|
set cwd_color (set_color $fish_color_cwd_root)
|
||||||
|
end
|
||||||
|
set suffix '#'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Color the prompt in red on error
|
||||||
|
if test $last_status -ne 0
|
||||||
|
set status_color (set_color $fish_color_error)
|
||||||
|
set prompt_status $status_color "[" $last_status "]" $normal
|
||||||
|
end
|
||||||
|
|
||||||
|
echo -s (prompt_login) ' ' $cwd_color (prompt_pwd) $vcs_color (fish_vcs_prompt) $normal ' ' $prompt_status
|
||||||
|
echo -n -s $status_color $suffix ' ' $normal
|
||||||
|
end
|
||||||
|
|
||||||
|
### Interactive
|
||||||
# Default is brblack (bright0)
|
# Default is brblack (bright0)
|
||||||
set -g fish_color_autosuggestion brgreen
|
set -g fish_color_autosuggestion brgreen
|
||||||
|
|
||||||
|
@ -232,10 +228,6 @@ in {
|
||||||
function activate -d 'Activate Python venv'
|
function activate -d 'Activate Python venv'
|
||||||
source .venv/bin/activate.fish
|
source .venv/bin/activate.fish
|
||||||
end
|
end
|
||||||
|
|
||||||
function arknights -d 'Launch Arknights'
|
|
||||||
waydroid app launch com.YoStarEN.Arknights
|
|
||||||
end
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue