From c5ce2f13eb5a3bdeab4fa5ff383144879777c992 Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Mon, 20 Jun 2022 00:39:52 -0300 Subject: [PATCH] change my prompt up --- home-manager/cli/starship.nix | 104 +++++++++++++++++++++++++-------- home-manager/trusted/afuse.nix | 9 ++- modules/home-manager/afuse.nix | 8 ++- 3 files changed, 95 insertions(+), 26 deletions(-) diff --git a/home-manager/cli/starship.nix b/home-manager/cli/starship.nix index 3966cc26..baf4ba15 100644 --- a/home-manager/cli/starship.nix +++ b/home-manager/cli/starship.nix @@ -1,47 +1,104 @@ +{ pkgs, ... }: +let + nix-inspect = pkgs.writeShellScriptBin "nix-inspect" '' + read -ra EXCLUDED <<< "$@" + + IFS=":" read -ra PATHS <<< "$PATH" + + read -ra PROGRAMS <<< \ + "$(printf "%s\n" "''${PATHS[@]}" | ${pkgs.gnugrep}/bin/grep "\/nix\/store" | ${pkgs.perl}/bin/perl -pe 's/^\/nix\/store\/\w{32}-((?:[^-\/]|-(?!(?:\d|unstable)))+)(?:-?([^\/]*))\/.*$/\1/' | ${pkgs.findutils}/bin/xargs)" + + for to_remove in "''${EXCLUDED[@]}"; do + PROGRAMS=("''${PROGRAMS[@]/$to_remove}") + done + + read -ra PROGRAMS <<< "''${PROGRAMS[@]}" + echo "''${PROGRAMS[@]}" + ''; +in { programs.starship = { enable = true; settings = { - format = '' - $username$hostname$shlvl $cmd_duration - $directory$git_branch$git_commit$git_state$git_status$hg_branch$docker_context$package$cmake$dart$dotnet$elixir$elm$erlang$golang$helm$java$julia$kotlin$nim$nodejs$ocaml$perl$php$purescript$python$ruby$rust$swift$terraform$zig$nix_shell$conda$memory_usage$aws$gcloud$openstack$env_var$crystal - $jobs$character - ''; + format = + let + git = "$git_branch$git_commit$git_state$git_status"; + cloud = "$aws$gcloud$openstack"; + in + '' + $username$hostname( $shlvl)( $cmd_duration) + ($nix_shell )''${custom.nix_inspect} + $directory( ${git})(- ${cloud}) + $jobs$character + ''; + + # Core username = { - show_always = true; format = "[$user]($style)"; + show_always = true; }; hostname = { - ssh_only = false; format = "[@$hostname]($style)"; + ssh_only = false; style = "bold green"; }; - directory = { }; - character = { - success_symbol = "[->>](bold green)"; - error_symbol = "[~~>](bold red)"; - vicmd_symbol = "[<<-](bold yellow)"; + shlvl = { + format = "[$shlvl]($style)"; + style = "bold cyan"; + threshold = 2; + repeat = true; }; - aws = { - symbol = " "; - format = "on [$symbol$profile(\\($region\\))]($style) "; + cmd_duration = { + format = "took [$duration]($style)"; }; - gcloud = { - symbol = " "; - format = "on [$symbol$active(/$project)(\\($region\\))]($style) "; + + directory = { + format = "[$path]($style)( [$read_only]($read_only_style))"; }; nix_shell = { + format = "via [$symbol$state( $name)]($style)"; impure_msg = ""; - pure_msg = "λ "; - symbol = ""; - format = "via [$symbol$state( $name)]($style) "; + pure_msg = "λ"; }; + custom = { + nix_inspect = { + disabled = false; + when = true; + command = "${nix-inspect}/bin/nix-inspect kitty imagemagick ncurses"; + format = "[$symbol(\\($output\\))]($style)"; + symbol = " "; + style = "bold cyan"; + }; + }; + + character = { + error_symbol = "[~~>](bold red)"; + success_symbol = "[->>](bold green)"; + vicmd_symbol = "[<<-](bold yellow)"; + }; + + # Cloud + gcloud = { + format = "on [$symbol$active(/$project)(\\($region\\))]($style)"; + }; + aws = { + format = "on [$symbol$profile(\\($region\\))]($style)"; + }; + + + # Toggles \/ + shlvl.disabled = false; + + + # Icon changes only \/ + aws.symbol = " "; conda.symbol = " "; dart.symbol = " "; - directory.read_only = " "; + directory.read_only = " "; docker_context.symbol = " "; elixir.symbol = " "; elm.symbol = " "; + gcloud.symbol = " "; git_branch.symbol = " "; golang.symbol = " "; hg_branch.symbol = " "; @@ -49,6 +106,7 @@ julia.symbol = " "; memory_usage.symbol = " "; nim.symbol = " "; + nix_shell.symbol = ""; nodejs.symbol = " "; package.symbol = " "; perl.symbol = " "; @@ -57,7 +115,7 @@ ruby.symbol = " "; rust.symbol = " "; scala.symbol = " "; - shlvl.symbol = " "; + shlvl.symbol = ""; swift.symbol = "ﯣ "; terraform.symbol = "行"; }; diff --git a/home-manager/trusted/afuse.nix b/home-manager/trusted/afuse.nix index 515d5b76..b69444ff 100644 --- a/home-manager/trusted/afuse.nix +++ b/home-manager/trusted/afuse.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, pkgs, ... }: let homeDir = config.home.homeDirectory; @@ -18,6 +18,13 @@ in mount_template = "${sshfs} %r:${homeDir} %m"; unmount_template = "${fusermount} -u -z %m"; populate_root_command = listTailscaleDevices; + + timeout = 300; + auto_unmount = true; + allow_root = true; + auto_cache = true; + remember = 10; + intr = true; }; }; } diff --git a/modules/home-manager/afuse.nix b/modules/home-manager/afuse.nix index 64d98c20..12be2757 100644 --- a/modules/home-manager/afuse.nix +++ b/modules/home-manager/afuse.nix @@ -16,7 +16,7 @@ let toArgument = n: v: with builtins; if null == v then "" else if false == v then "" - else if true == v then "-o ${v}" + else if true == v then "-o ${n}" else if isAttrs v then concatStringsSep " " (mapAttrsToList toArgument v) else "-o ${n}=\"${toValue v}\""; @@ -109,8 +109,12 @@ in systemd.user.services.afuse = { Unit.Description = "afuse automatic FUSE mounter"; Install.WantedBy = [ "default.target" ]; - Service.ExecStart = replaceStrings ["%"] ["%%"] # Extra percent to escape afuses' + Service = { + # Make sure mountpoint exists + ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${cfg.mountpoint}"; + ExecStart = replaceStrings ["%"] ["%%"] # Extra percent for escaping "${cfg.package}/bin/afuse ${optionalString cfg.debug "-d"} ${cfg.mountpoint} ${afuseArguments.generate null cfg.settings} -f"; + }; }; }; }