Last active
December 3, 2021 16:17
-
-
Save wknapik/bd6e3c4c75c85ad4c3a8e6fea640792e to your computer and use it in GitHub Desktop.
Revisions
-
wknapik revised this gist
Dec 3, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Requires: bash (I use it in zsh), coreutils, git. # Print link(s) to file(s) in repo(s), with optional line numbers. # $@ := file_path[:file_line] [ file_path2[:file_line2] [ ... ] ] -
wknapik revised this gist
Oct 20, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Requires: bash, coreutils, git. # Print link(s) to file(s) in repo(s), with optional line numbers. # $@ := file_path[:file_line] [ file_path2[:file_line2] [ ... ] ] repolink() { local branch f file host origin url_path -
wknapik revised this gist
Oct 20, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ # Print link(s) to file(s) in a repository, with optional line numbers. # $@ := file_path[:file_line] [ file_path2[:file_line2] [ ... ] ] repolink() { local branch f file host origin url_path for f in "$@"; do file="$(realpath "$f")" checkout_path="$(git -C "$(dirname "$file")" rev-parse --show-toplevel)" -
wknapik revised this gist
Oct 20, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # Requires: bash, coreutils, git. # Print link(s) to file(s) in a repository, with optional line numbers. # $@ := file_path[:file_line] [ file_path2[:file_line2] [ ... ] ] repolink() { -
wknapik renamed this gist
Oct 20, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
wknapik created this gist
Oct 20, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ # Print link(s) to file(s) in a repository, with optional line numbers. # $@ := file_path[:file_line] [ file_path2[:file_line2] [ ... ] ] repolink() { local branch f file host origin for f in "$@"; do file="$(realpath "$f")" checkout_path="$(git -C "$(dirname "$file")" rev-parse --show-toplevel)" origin="$(git -C "$checkout_path" config --get remote.origin.url)" branch="$(git -C "$checkout_path" rev-parse --abbrev-ref HEAD)" host="${origin#*://}" # strip off scheme host="${host#*@}" # strip off user host="${host/:[0-9]*\//\/}" # strip off port host="${host//://}" # replace : with / host="${host%.git}" # strip off .git suffix host="${host%/}" # strip off trailing / url_path="${file#"$checkout_path"/}" echo "https://$host/blob/$branch/${url_path/:/#L}" done }