Create git open command#
This command will open the current repo in the browser
-
Create a
binfolder in user profile directory1 2 3 4
``` bash cd ~ mkdir bin ``` -
Add
binto your PATH1 2 3
``` bash vim ~/.bash_profile ``` -
Inside .bash_profile Add
1 2 3
``` bash export PATH=~/bin:$PATH ``` -
Navigate to bin folder and create a new file called
git-open. Note, omit the.shfrom the file name1 2 3 4
``` bash cd ~/bin vim git-open ``` -
Add the following code to
git-open1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
``` bash #!/bin/bash isGitRepo=`git rev-parse --is-inside-work-tree` if [ 'true' != "$isGitRepo" ]; then exit 1 fi start='cmd.exe /c start' remote=`git remote get-url origin` url="${remote/ssh/https}" url="${url/:22/}" $start $url; ``` -
Give new
git-openscript excute1 2 3 4
``` bash cd ~/bin chmod +x git-open ```
Now you can run the script using git open command.
Last update:
2022-02-12 16:09:48