Add tada to vim, fix prompt bugs
Jes Olson j3s@c3f.net
Tue, 21 Jun 2022 16:51:19 -0500
5 files changed,
24 insertions(+),
19 deletions(-)
M
.config/git/config
→
.config/git/config
@@ -37,9 +37,9 @@ name = Jes Olson
email = j3s@c3f.net [pull] ff = only -[includeIf "gitdir:~/do/"] - path = ~/.config/git/config-work [pager] status = true [init] defaultBranch = main +[includeIf "gitdir:~/do/"] + path = ~/.config/git/config-work
M
.config/git/config-work
→
.config/git/config-work
@@ -3,5 +3,7 @@ name = Jes Olson
email = jolson@digitalocean.com [changelog] format = * %s [%an] -[url "git@github.internal.digitalocean.com:"] +[url "ssh://git@github.com/"] + insteadOf = https://github.com/ +[url "ssh://git@github.internal.digitalocean.com/"] insteadOf = https://github.internal.digitalocean.com/
M
.config/nvim/init.vim
→
.config/nvim/init.vim
@@ -6,6 +6,7 @@ Plug 'vhyrro/neorg'
Plug 'hrsh7th/nvim-compe' Plug 'ctrlpvim/ctrlp.vim' Plug 'cormacrelf/vim-colors-github' +Plug 'dewyze/vim-tada' call plug#end() colorscheme github
M
bin/prompt.go
→
bin/prompt.go
@@ -11,16 +11,14 @@ )
// getRepoRoot returns the full path to the root // of the closest git dir -func getRepoRoot() string { - var rootPath string - +func gitTopLevel() string { path, err := exec.Command("git", "rev-parse", "--show-toplevel").Output() if err != nil { - rootPath = "~" - } else { - rootPath = strings.TrimSpace(string(path)) + // assume the error means there's no git + // dir above us + return "/" } - return rootPath + return strings.TrimSpace(string(path)) } func resolveEmoji(hostname string) string {@@ -34,23 +32,27 @@ return emoji
} func main() { - cwd, _ := os.Getwd() + wd, _ := os.Getwd() + cwd, _ := filepath.EvalSymlinks(wd) host, _ := os.Hostname() home := os.Getenv("HOME") now := time.Now().Format("15:04:05") emoji := resolveEmoji(host) fmt.Printf("%s %s ", now, emoji) - gitRoot := getRepoRoot() - - var prefix string - if gitRoot == home { - prefix = "~" + var promptRoot string + gitTop := gitTopLevel() + if gitTop == home { + promptRoot = "~" } else { - prefix = filepath.Base(gitRoot) + promptRoot = filepath.Base(gitTop) } - suffix := cwd[len(gitRoot):] - fmt.Printf("%s", prefix) + // subtract the git toplevel "/home/j3s" + // from the cwd "/home/j3s/code/nongitdir" + // to get the suffix "/code/nongitdir" + // os.cwd gets the symlink, git does not + suffix := cwd[len(gitTop):] + fmt.Printf("%s", promptRoot) var parts []string parts = strings.Split(suffix, "/")