diff --git a/users/simon/modules/zsh/0001-feat-directory-allow-disabling-repo-integration.patch b/users/simon/modules/zsh/0001-feat-directory-allow-disabling-repo-integration.patch new file mode 100644 index 0000000..3344dd9 --- /dev/null +++ b/users/simon/modules/zsh/0001-feat-directory-allow-disabling-repo-integration.patch @@ -0,0 +1,52 @@ +From 3ded2fd2f67357b986821a36d815853b16c19411 Mon Sep 17 00:00:00 2001 +From: Simon Bruder +Date: Tue, 9 Aug 2022 00:55:55 +0200 +Subject: [PATCH] feat(directory): allow disabling repo integration + +If the directory is a network mount, this can be slowing starship down +which makes the shell feel unresponsive. +--- + src/configs/directory.rs | 2 ++ + src/modules/directory.rs | 6 +++++- + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/src/configs/directory.rs b/src/configs/directory.rs +index 32c72fb6..fce3fd76 100644 +--- a/src/configs/directory.rs ++++ b/src/configs/directory.rs +@@ -21,6 +21,7 @@ pub struct DirectoryConfig<'a> { + pub truncation_symbol: &'a str, + pub home_symbol: &'a str, + pub use_os_path_sep: bool, ++ pub disable_repo: bool, + } + + impl<'a> Default for DirectoryConfig<'a> { +@@ -41,6 +42,7 @@ impl<'a> Default for DirectoryConfig<'a> { + truncation_symbol: "", + home_symbol: "~", + use_os_path_sep: true, ++ disable_repo: false, + } + } + } +diff --git a/src/modules/directory.rs b/src/modules/directory.rs +index 873dfde9..03c31314 100644 +--- a/src/modules/directory.rs ++++ b/src/modules/directory.rs +@@ -51,7 +51,11 @@ pub fn module<'a>(context: &'a Context) -> Option> { + + // Attempt repository path contraction (if we are in a git repository) + // Otherwise use the logical path, automatically contracting +- let repo = context.get_repo().ok(); ++ let repo = if config.disable_repo { ++ None ++ } else { ++ context.get_repo().ok() ++ }; + let dir_string = if config.truncate_to_repo { + repo.and_then(|r| r.workdir.as_ref()) + .filter(|&root| root != &home_dir) +-- +2.36.0 + diff --git a/users/simon/modules/zsh/default.nix b/users/simon/modules/zsh/default.nix index 321401c..cc5526c 100644 --- a/users/simon/modules/zsh/default.nix +++ b/users/simon/modules/zsh/default.nix @@ -1,4 +1,4 @@ -{ lib, nixosConfig, pkgs, ... }: +{ config, lib, nixosConfig, pkgs, ... }: let solarized = (import ../common.nix).colorschemes.solarized; @@ -59,6 +59,11 @@ in nix-index.enable = true; starship = { enable = true; + package = pkgs.starship.overrideAttrs (o: o // { + patches = o.patches ++ [ + ./0001-feat-directory-allow-disabling-repo-integration.patch + ]; + }); settings = { add_newline = false; }; @@ -118,4 +123,14 @@ in ]; }; }; + + home.file."mounts/.envrc".text = '' + export STARSHIP_CONFIG=${(pkgs.formats.toml { }).generate "starship-config-network" (config.programs.starship.settings // { + directory.disable_repo = true; # custom option, patched (see above) + git_branch.disabled = true; + git_commit.disabled = true; + git_state.disabled = true; + git_status.disabled = true; + })} + ''; }