Compare commits
2 commits
1b51633d4f
...
beb880ed43
Author | SHA1 | Date | |
---|---|---|---|
beb880ed43 | |||
449c460bbb |
4 changed files with 7 additions and 3 deletions
|
@ -135,6 +135,9 @@ Default: '>'
|
||||||
.It Ev REMUX_NEW_WINDOW
|
.It Ev REMUX_NEW_WINDOW
|
||||||
Provides a default windows name when creating a new session. Unused if empty.
|
Provides a default windows name when creating a new session. Unused if empty.
|
||||||
Default: (unset)
|
Default: (unset)
|
||||||
|
.It Ev REMUX_REPO_FILE
|
||||||
|
The filename to match on when trying to find the root of a repository.
|
||||||
|
Default: '.git'
|
||||||
.El
|
.El
|
||||||
.Sh EXIT STATUS
|
.Sh EXIT STATUS
|
||||||
.Bl -tag -Width Ds
|
.Bl -tag -Width Ds
|
||||||
|
|
|
@ -5,6 +5,7 @@ pub type EnvVar = (&'static str, &'static str);
|
||||||
pub static ATTACH_SYMBOL: EnvVar = ("REMUX_ATTACH_SYMBOL", "*");
|
pub static ATTACH_SYMBOL: EnvVar = ("REMUX_ATTACH_SYMBOL", "*");
|
||||||
pub static CURRENT_SYMBOL: EnvVar = ("REMUX_CURRENT_SYMBOL", ">");
|
pub static CURRENT_SYMBOL: EnvVar = ("REMUX_CURRENT_SYMBOL", ">");
|
||||||
pub static NEW_WINDOW_NAME: EnvVar = ("REMUX_NEW_WINDOW", "");
|
pub static NEW_WINDOW_NAME: EnvVar = ("REMUX_NEW_WINDOW", "");
|
||||||
|
pub static REPO_FILE: EnvVar = ("REMUX_REPO_FILE", ".git");
|
||||||
|
|
||||||
pub static TMUX: &str = "TMUX";
|
pub static TMUX: &str = "TMUX";
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
||||||
use pico_args::Arguments;
|
use pico_args::Arguments;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
env::TMUX,
|
env::{ env_var, REPO_FILE, TMUX },
|
||||||
error,
|
error,
|
||||||
flag::Flags,
|
flag::Flags,
|
||||||
util::{ find, session_name }
|
util::{ find, session_name }
|
||||||
|
@ -82,7 +82,7 @@ pub struct Repository {
|
||||||
|
|
||||||
impl Repository {
|
impl Repository {
|
||||||
pub fn find() -> Option<Repository> {
|
pub fn find() -> Option<Repository> {
|
||||||
let path = find(".git", env::current_dir().unwrap());
|
let path = find(&env_var(REPO_FILE), env::current_dir().unwrap());
|
||||||
if let Some(path) = path {
|
if let Some(path) = path {
|
||||||
let name = path.file_name().unwrap().to_string_lossy().to_string();
|
let name = path.file_name().unwrap().to_string_lossy().to_string();
|
||||||
let inner = Repository {
|
let inner = Repository {
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub fn terminal_enforce() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// recursively propagate up directories to find a child
|
/// recursively propagate up directories to find a child
|
||||||
pub fn find(target: &'static str, path: PathBuf) -> Option<PathBuf> {
|
pub fn find(target: &str, path: PathBuf) -> Option<PathBuf> {
|
||||||
if path.join(target).exists() { return Some(path); }
|
if path.join(target).exists() { return Some(path); }
|
||||||
|
|
||||||
let parent = path.parent();
|
let parent = path.parent();
|
||||||
|
|
Loading…
Reference in a new issue