-
Notifications
You must be signed in to change notification settings - Fork 335
Auto Git Config Script Added and Tab_Data TOML Updated. #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d430358
78cad31
5040b27
5947b33
bb095b0
8c7557b
8a14b10
b7134ce
521c8e5
ff70494
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/sh -e | ||
|
||
# Import common utilities | ||
. ../common-script.sh | ||
|
||
# Function to prompt for GitHub configuration | ||
setup_git_config() { | ||
# Prompt for GitHub email | ||
printf "Enter your GitHub email address: " | ||
read email | ||
|
||
# Prompt for SSH key type | ||
echo "Choose your SSH key type:" | ||
echo "1. Ed25519 (recommended)" | ||
echo "2. RSA (legacy)" | ||
printf "Enter your choice (1 or 2): " | ||
read key_type | ||
|
||
# Set key algorithm based on user choice | ||
case "$key_type" in | ||
1) key_algo="ed25519" ;; | ||
2) key_algo="rsa" ;; | ||
*) | ||
echo "Invalid choice. Exiting." | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Prompt for custom key name | ||
printf "Enter a custom SSH key name (leave blank for default): " | ||
read key_name | ||
|
||
# Set the SSH key path based on user input | ||
ssh_key_path="${HOME}/.ssh/${key_name:-id_$key_algo}" | ||
|
||
# Generate SSH key with specified type and email | ||
ssh-keygen -t "$key_algo" -C "$email" -f "$ssh_key_path" | ||
|
||
# Prompt for passphrase usage | ||
printf "Do you want to use a passphrase? (y/n): " | ||
read use_passphrase | ||
|
||
# If user opts for a passphrase, add key to SSH agent | ||
if [ "$use_passphrase" = "y" ]; then | ||
ssh-add -l >/dev/null 2>&1 || eval "$(ssh-agent -s)" | ||
ssh-add "$ssh_key_path" | ||
else | ||
echo "Skipping passphrase setup." | ||
fi | ||
fam007e marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
echo "SSH key generation and setup completed." | ||
} | ||
|
||
# Function to copy the SSH key to the clipboard and prompt user to add it to GitHub | ||
copy_and_confirm_ssh_key() { | ||
# Check if xclip is installed | ||
checkCommandRequirements "xclip" | ||
|
||
# Copy the generated public key to the clipboard using xclip | ||
if command -v xclip >/dev/null 2>&1; then | ||
cat "${ssh_key_path}.pub" | xclip -selection clipboard | ||
echo "Your SSH public key has been copied to the clipboard." | ||
else | ||
echo "xclip not found. Please manually copy the SSH key." | ||
cat "${ssh_key_path}.pub" | ||
fi | ||
|
||
# Prompt user to confirm they've added the key to GitHub | ||
while true; do | ||
printf "Have you pasted your SSH public key into your GitHub account? (y/n): " | ||
read yn | ||
case "$yn" in | ||
[Yy]* ) echo "Proceeding..."; break ;; | ||
[Nn]* ) echo "Please paste your SSH public key into GitHub and try again."; exit ;; | ||
* ) echo "Please answer yes (y) or no (n)." ;; | ||
esac | ||
done | ||
|
||
# Test the SSH connection with GitHub | ||
ssh -T git@github.com | ||
} | ||
|
||
|
||
# Main execution | ||
checkEnv | ||
setup_git_config | ||
copy_and_confirm_ssh_key |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -51,3 +51,7 @@ script = "3-global-theme.sh" | |||
[[data]] | ||||
name = "Remove Snaps" | ||||
script = "4-remove-snaps.sh" | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Remove this line... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fam007e ONCE AGAIN, this extra line has not been removed, please remove it |
||||
[[data]] | ||||
name = "Git Auto-conf CLI" | ||||
script = "git-auto-conf-cli.sh" | ||||
fam007e marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.