Created
October 3, 2023 01:26
-
-
Save andresjesse/7b57f6605655258f50d995b1e7ad918c to your computer and use it in GitHub Desktop.
This file contains 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 characters
#!/usr/bin/python3 | |
# Changelog: | |
# 2023-10-02: initial version | |
# To install: | |
# chmod a+x ssh-git-cmd.py | |
# sudo ln -s $(pwd)/ssh-git-cmd.py /usr/local/bin/ssh-git-cmd.py | |
import os, sys | |
from pathlib import Path | |
dirs = os.listdir(str(Path.home())+'/.ssh') | |
print("Select SSH Key for repository:") | |
for index, ssh_key in enumerate(dirs): | |
if ssh_key.endswith(".pub"): | |
print('\t', index, ssh_key) | |
x = int(input()) | |
cmd = 'git -c core.sshCommand="ssh -i '+str(Path.home())+'/.ssh/'+dirs[x][:-4]+'" '+' '.join(sys.argv[1:]) | |
print('Executing:') | |
print('\t',cmd) | |
os.system(cmd) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment