Skip to content

Instantly share code, notes, and snippets.

@ismailmustafa
Created December 4, 2015 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismailmustafa/e539ba8965f83908a684 to your computer and use it in GitHub Desktop.
Save ismailmustafa/e539ba8965f83908a684 to your computer and use it in GitHub Desktop.
#!/bin/bash
#Script that opens github link to you repository from terminal
set -e
remote=$(git remote -v)
# split on colon
IFS=':' read -ra split_colon <<< "$remote"
partial=${split_colon[${#split_colon[@]} - 1]}
# split on space
IFS=' ' read -ra split_space <<< "$partial"
partial2=${split_space[0]}
# split on dot
IFS='.' read -ra split_dot <<< "$partial2"
partial3=${split_dot[0]}
# concatenate to form link
github_link="https://github.com/"
repository_link=$github_link$partial3
# open link
open "$repository_link"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment