From dd6c54f089933a627f7fd2758aeec641cd384e1e Mon Sep 17 00:00:00 2001 From: Denis Isidoro Date: Mon, 16 Mar 2020 08:13:55 -0300 Subject: [PATCH] wip --- scripts/install | 12 ++++++++++++ src/git.rs | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 5fd90f1..e6930f2 100755 --- a/scripts/install +++ b/scripts/install @@ -113,6 +113,18 @@ get_shell() { echo $SHELL | xargs basename } +installation_finish_instructions() { + local -r shell="$(get_shell)" + echoerr -e "Finished. To call navi, restart your shell or reload the config file:\n source ~/.${shell}rc" + local code + if [[ $shell = "zsh" ]]; then + code="navi widget ${shell} | source" + else + code="source <(navi widget ${shell})" + fi + echoerr -e "\nTo add the Ctrl-G keybinding, add the following to ~/.${shell}rc:\n ${code}" +} + install_navi() { export SOURCE_DIR="${SOURCE_DIR:-"$(get_source_dir)"}" export BIN_DIR="${BIN_DIR:-"$(get_bin_dir)"}" diff --git a/src/git.rs b/src/git.rs index efd7114..72100dc 100644 --- a/src/git.rs +++ b/src/git.rs @@ -2,7 +2,7 @@ pub fn meta(uri: &str) -> (String, String, String) { let actual_uri = if uri.contains("://") { uri.to_string() } else if uri.contains('@') { - uri.replace("git@", "https://").replace(':', "/") + uri.replace(':', "/").replace("git@", "https://") } else { format!("https://github.com/{}", uri) }; @@ -29,9 +29,9 @@ mod tests { #[test] fn test_meta_github_ssh() { let (actual_uri, user, repo) = meta("git@github.com:denisidoro/navi.git"); - assert_eq!(actual_uri, "https://github.com/denisidoro/navi".to_string()); + assert_eq!(actual_uri, "https://github.com/denisidoro/navi.git".to_string()); assert_eq!(user, "denisidoro".to_string()); - assert_eq!(repo.contains("navi"), true); + assert_eq!(repo, "navi".to_string()); } #[test] @@ -39,6 +39,6 @@ mod tests { let (actual_uri, user, repo) = meta("https://gitlab.com/user/repo.git"); assert_eq!(actual_uri, "https://gitlab.com/user/repo.git".to_string()); assert_eq!(user, "user".to_string()); - assert_eq!(repo.contains("repo"), true); + assert_eq!(repo, "repo".to_string()); } }