all repos

dotfiles @ e124f15fea49448f4be5da58fae769da4ca40058

i use rach linux btw

dotfiles/bin/tmux-open-git.sh (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
tmux: add script for opening current git repo on the web, 1 month ago
1
#!/usr/bin/env bash
2
3
p="$(tmux run 'echo #{pane_current_path}')"
4
cd "$p"
5
url=$(git remote get-url origin 2>/dev/null) || { echo "No remote 'origin' found in $p"; exit 1; }
6
7
if [[ $url == git@* ]]; then
8
  url="${url#git@}"
9
  url="${url/://}"
10
  url="https://$url"
11
fi
12
13
url="${url%.git}"
14
if [[ $url == https://* || $url == http://* ]]; then open "$url"
15
else echo "Cannot open: unrecognized remote format: $url: in $p"
16
     exit 1
17
fi
18
19
if command -v xdg-open &>/dev/null; then xdg-open "$url" >/dev/null
20
elif command -v open &>/dev/null;   then open "$url" >/dev/null
21
else tmux display-message "no opener found: $url" ; exit 1
22
fi
23
24
tmux display-message "opened: $url"