我经常需要使用命令行替换我的默认 git osxkeychain 凭据。我手动操作的方式如下:
git credential-osxkeychain erase <Enter>host=github.com <Enter>protocol=https <Enter>password=foo <Enter>username=bar <Enter><Enter><Enter>
然后再次执行该过程,但使用git credential-osxkeychain store新凭据除外。我想自动化它,比如
alias git_newcred='git credential-osxkeychain erase; host=github.com; protocol=https;git credential-osxkeychain erase; host=github.com; protocol=https;'
换行符;代替 enter 键的位置。然而,就这样默默地失败了。
read_credential源代码中方法的开头如下所示:
while (fgets(buf, sizeof(buf), stdin)) {
char *v;
if (!strcmp(buf, "\n"))
break;
buf[strlen(buf)-1] = '\0';
如何给作为单个命令一部分的多行条目起别名?还是有更好的方法来做到这一点?
(使用 zsh,但我不认为有任何特定于 zsh 的事情发生。)