I regularly need to replace my default git osxkeychain credentials, using the command-line. The way I do it manually is as follows:
git credential-osxkeychain erase
<Enter>
host=github.com
<Enter>
protocol=https
<Enter>
password=foo
<Enter>
username=bar
<Enter>
<Enter><Enter>
And then that process again, except with git credential-osxkeychain store
and the new credentials. I'd like to automate it, something like
alias git_newcred='git credential-osxkeychain erase; host=github.com; protocol=https;git credential-osxkeychain erase; host=github.com; protocol=https;'
Where the ;
newlines are in place of the enter key. However, as it is this fails silently.
The beginning of the read_credential
method in the source looks like this:
while (fgets(buf, sizeof(buf), stdin)) {
char *v;
if (!strcmp(buf, "\n"))
break;
buf[strlen(buf)-1] = '\0';
How do I alias multi-line entry, which is part of a single command? Or is there a better way to do this?
(Using zsh, but I don't think there's anything zsh-specific going on.)