I want to create a git alias which will allow me to do git visit and the repository will be opened in the browser.
CodePudding user response:
When you type a command such as git xyz, git looks for a file named git-xyz and if found, it executes it. You can simulate such behavior by putting a file named git-visit in a directory which is in the PATH, and then git visit will execute it.
The content of the file should be
xdg-open $(git remote -v | cut -d @ -f 2 | cut -d ' ' -f 1 | head -1 | sed 's/:/\//' | sed 's/.git$//' | sed s'/^/https:\/\//') >& /dev/null &
(xdg-open might not work on your machine).
Note that you must do chmod x git-xyz in order to make the file executable
CodePudding user response:
If this repo has a GitHub remote, you can say hub browse (if you have installed hub).
