从我的 Xcode 版本文件切换到它的 github/gitlab 网络版本

Switch from my Xcode versioned file to its github/gitlab web version

我经常使用 GithubGitlab 与我的同事分享 link 我的代码很酷线锚特征(即:https://github.com/Phonations/Joker/blob/master/.travis.yml#L12-L16)。

我正在寻找一种快速从我的文件跳转到其网络版本的方法。有谁知道执行此操作的技巧或扩展吗?

如果可以从终端执行,那就太好了!

我为 GithubBitBucker 分叉并修补了这个不错的 XCode 扩展,现在可以使用Gitlab: https://github.com/larsxschneider/ShowInGitHub

您可以使用这个(还)不完美的脚本:

if [ "$#" -ne 3 ]; then
    echo "Illegal number of parameters, usage: script file lineStart lineEnd";
    echo "Example : test.sh .travis.yml 12 16";
    exit 255;
fi

branch=`git rev-parse --abbrev-ref HEAD`;
repo=`git config --get remote.origin.url | sed 's/\.git//g'`;

echo $repo"/blob/"$branch"/"#L-L;

这样做。用法:

path/to/script.sh file lineStart lineEnd

如果你想将它复制到剪贴板(因为我看到你在 mac)将它传送到 pbcopy:

path/to/script.sh file lineStart lineEnd | pbcopy

当然你可以把它包装成一个函数。

旁注:要使用它 pwd 必须是您的 git 存储库的根目录。