exe/git-switcher in git-switcher-1.0.6 vs exe/git-switcher in git-switcher-1.0.7

- old
+ new

@@ -16,17 +16,30 @@ menu = Git::Switcher::Menu.for(repo) # (optional) script to run after every checkout switcher = File.join(repo.workdir, '.switcher') +run_switcher = true + loop do print "\e[H\e[2J", menu, "\n", "\n" # clear the screen first (^L) + if run_switcher && File.executable?(switcher) + print Rainbow('Switcher message:').italic.underline, "\n" + + cmd_msg = `2>&1 #{switcher}` + putm(cmd_msg, :green) + + run_switcher = false + next # re-start loop + end + if (default_menu_item = menu.default_menu_item) default_shortcut = format('⏎ [%2s]', default_menu_item.shortcut) print Rainbow(default_shortcut).bold.steelblue, ' ' end + print "\t", Rainbow('your selection =>').steelblue, ' ' response = begin $stdin.gets&.strip rescue Interrupt @@ -42,12 +55,12 @@ end next unless menu_item err_msg = `2>&1 git checkout --quiet #{menu_item.reference.name}` - if $CHILD_STATUS.success? && File.executable?(switcher) - cmd_msg = `2>&1 #{switcher}` - putm(cmd_msg, :green) + + if $CHILD_STATUS.success? + run_switcher = true else putm(err_msg, :red) end end