πŸ—οΈ Quick macOS Tip: Open Keychain Access from Terminal! πŸ” - Update git credentials

Sh Raj - Apr 6 - - Dev Community

πŸ—οΈ Quick macOS Tip: Open Keychain Access from Terminal! πŸ”

Hey there, macOS users! Ever found yourself digging through your Applications folder just to open up Keychain Access? πŸ•΅οΈβ€β™‚οΈ Let's save you some clicks with this super quick Terminal trick! πŸ’»πŸš€

So, What's Keychain Access?

If you're not familiar, Keychain Access is like the secret vault where macOS stores all your passwords, certificates, and secure notes. It's where the magic happens when your Mac autofills your passwords or remembers your Wi-Fi details. πŸŒŸπŸ”’

Why Open It from Terminal?

Maybe you're a Terminal aficionado who loves shortcuts, or maybe you just want to impress your friends with your command-line wizardry! Either way, opening Keychain Access from Terminal is a nifty trick to add to your macOS toolbox. βš’οΈβœ¨

The Command πŸ› οΈ

Let's dive right in! Open your Terminal app (you can find it in Applications > Utilities), and type or copy-paste this magic incantation:

open -a "Keychain Access" --background
Enter fullscreen mode Exit fullscreen mode

Hit Enter, and like magic, the Keychain Access app will open up in the background! 🌈✨ No more clicking through menus or searching through folders.

Updating Git Credentials πŸ”„

Here's a bonus tip: Did you know you can update your Git credentials directly from Keychain Access? If you've changed your GitHub password or want to update your saved credentials, follow these steps:

  1. Open Keychain Access using the Terminal command we just learned.
  2. In the search bar at the top right, type "git" to filter the results.
  3. Find the entry for git:github.com or any other Git service you use.
  4. Double-click on the entry to open its details.
  5. Click on the "Attributes" tab, then check the "Show Password" box.
  6. Update the password to your new GitHub Personal Access Token.
  7. Close the window, and Keychain Access will save your changes.

Updating Git Credentials from Terminal

If you prefer the command line, you can update your Git credentials directly from the Terminal. First, let's clear the existing credentials:

git credential-store --file ~/.git-credentials erase
protocol=https
host=github.com
Enter fullscreen mode Exit fullscreen mode

Then add your new GitHub PAT:

git credential-store --file ~/.git-credentials store << EOF
protocol=https
host=github.com
username=YourGitHubUsername
password=YourPersonalAccessToken
EOF
Enter fullscreen mode Exit fullscreen mode

Replace YourGitHubUsername with your GitHub username and YourPersonalAccessToken with the token you generated.

Bonus: Create a Terminal Shortcut πŸš€

If you're like me and prefer even quicker access, you can set up a custom shortcut. Open up your ~/.bash_profile or ~/.zshrc file (depending on which shell you use) and add this line:

alias keychain="open -a 'Keychain Access' --background"
Enter fullscreen mode Exit fullscreen mode

Save the file, then the next time you open Terminal, you can just type keychain and voilΓ ! Keychain Access will appear, ready for your secret password quest. πŸ”‘πŸŽ‰

Wrapping Up πŸ”—

And there you have it, a simple yet powerful trick to open Keychain Access directly from Terminal. 🎩✨ Whether you're a command-line guru or just looking to streamline your workflow, this little hack can save you time and clicks.

P.S. Need more Terminal tricks or macOS hacks? Let me know in the comments below! πŸ‘‡

Feel free to tweak and personalize this for your Dev.to article, and don't forget to sprinkle in some fun emojis along the way! πŸŽ‰βœ¨

Gif Illustrations πŸ–ΌοΈ

  1. Opening Keychain Access from Terminal:
    Opening Keychain Access

  2. Updating Git Credentials in Keychain Access:
    Updating Git Credentials

Enjoy your newfound command-line prowess! πŸš€βœ¨

P.S. Need more Terminal tricks or macOS hacks? Let me know in the comments below! πŸ‘‡

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .