From 60d936dfbaa259c6f04cf1361955e6087c3aef78 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 20 Feb 2018 23:11:07 +0100 Subject: git-branch-list(save_branch): Don't add branch if already saved Don't add existing branches to the database. We don't want any duplicate branch names cluttering the shortcut list. --- git-branch-list | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-branch-list b/git-branch-list index 2569dc0..bd85160 100755 --- a/git-branch-list +++ b/git-branch-list @@ -23,10 +23,13 @@ function save_branch () { # # echo "$branch" >> "$DATABASE" + if fgrep "$branch" "$DATABASE" > /dev/null; then + return 1 + fi + cat <(echo "$branch") "$DATABASE" > "${DATABASE}.bak" mv "${DATABASE}.bak" "$DATABASE" - # TODO: don't save if already added # TODO: append instead of prepend so IDs stay the same. Maybe? } -- cgit v1.2.3