53 lines
1.7 KiB
Diff
53 lines
1.7 KiB
Diff
From 3ded2fd2f67357b986821a36d815853b16c19411 Mon Sep 17 00:00:00 2001
|
|
From: Simon Bruder <simon@sbruder.de>
|
|
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<Module<'a>> {
|
|
|
|
// 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
|
|
|