Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 529

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 62k
Author
Asked: November 25, 20242024-11-25T11:44:09+00:00 2024-11-25T11:44:09+00:00

My favorite bash shortcuts in 2023

  • 62k

I use fishshell, and its Oh my fish framework as my command line shell. Over the years, I have gathered many useful functions and shortcuts. Here are my favorites.

General shortcuts

Let's start with some general shortcuts. The first one is the brc shortcut which reloads the .bashrc file and refreshes its content. That way, I can use new shortcuts if added.

alias brc="source ~/.config/fish/.bashrc" 
Enter fullscreen mode Exit fullscreen mode

Since I am using VS Code Insiders, whose command in the terminal is code-insiders, which I am too lazy to write every time, I have added a ci shortcut.

alias ci="code-insiders" 
Enter fullscreen mode Exit fullscreen mode

Sometimes I use The Fuck app for my terminal, but it might be inconvenient when sharing screen. So, I use a shortcut pls to run fuck command.

alias pls=fuck 
Enter fullscreen mode Exit fullscreen mode

SSH shortcuts

Recently Josie posted on Twitter how she cannot remember how to add the SSH key.

“I have been a software engineer for 7 years and I will never remember the steps to adding a SSH key to my Github profile I'm so sorry.”

— Josie on Twitter

It reminded me of the SSH shortcuts that I configured many years ago. So here are my SSH shortcuts.

To generate a new SSH key, I use the sshkey shortcut with an additional argument, the SSH user filename, like so sshkey pgh_rsa.

function sshAddKey  ssh-keygen -t rsa -C $argvendalias sshkey=sshAddKey 
Enter fullscreen mode Exit fullscreen mode

To start the SSH agent and add the SSH key, I use the sshuser shortcut with an additional argument, the SSH user filename, like so sshuser pgh_rsa.

function sshStart  eval ssh-agent -s  ssh-add ~/.ssh/$argv[1]endalias sshuser=sshStart 
Enter fullscreen mode Exit fullscreen mode

To delete all identities from the agent, I use the sshdel shortcut.

alias sshdel="ssh-add -D" 
Enter fullscreen mode Exit fullscreen mode

To test the SSH connection to GitHub, I use the sshpingg shortcut.

alias sshpingg="ssh -T git@github.com" 
Enter fullscreen mode Exit fullscreen mode

Handling terminal processes shortcuts

Since I use Gulp, 11ty, and custom Node.js scripts in my workflow, I have situations where I need to kill a process or two that are stuck or hanging.

To check if a process already occupies a port, I use the checkPort shortcut with am additional argument, the port, like so checkPort 8080.

function checkPort  lsof -t -i:$argv[1]endalias cport=checkPort 
Enter fullscreen mode Exit fullscreen mode

To terminate all processes that occupy a port, I use the kport shortcut with an additional argument, the port, like so kport 8080.

function killPort  kill -9 (lsof -t -i:$argv[1])endalias kport=killPort 
Enter fullscreen mode Exit fullscreen mode

To terminate all running Node.js processes, I use the killnode shortcut.

alias killnode="killall -9 node" 
Enter fullscreen mode Exit fullscreen mode

To terminate all running Node.js processes, I use the kf shortcut.

alias kf="killify" 
Enter fullscreen mode Exit fullscreen mode

kf is just an alias for my killify NPM package.

Filesystem shortcuts

For general filesystem navigation in my terminal, I'm using z command. But for finer control, I am using the following commands.

To go up one level, I use cd.. and .. commands.

alias cd..="cd .."alias ..="cd .." 
Enter fullscreen mode Exit fullscreen mode

To see the long listing format of the current folder, I use the ll and lll shortcuts. To see every single file and folder within current folder, I use the llll shortcut.

alias ll="ls -la"alias lll="exa -abghHliS"function exaTree  exa --long --tree $argvendalias llll=exaTree 
Enter fullscreen mode Exit fullscreen mode

To remove folders and files, I use the rr and rrr shortcuts. The difference is that the rr shortcut shows prompt before removal.

alias rr="rm -rf -i"alias rrr="rm -rf" 
Enter fullscreen mode Exit fullscreen mode

Use rm -rf with extreme caution. The action cannot be reverted, and all deleted files and folders are permanently gone.

Git shortcuts

I am using a lot of Git shortcuts, but here are my favorites.

To check the git status, I use the gs shortcut.

alias gs="git status -s" 
Enter fullscreen mode Exit fullscreen mode

To view the git log, I use the gl shortcut.

alias gl="git log --oneline --graph" 
Enter fullscreen mode Exit fullscreen mode

To stash every new, removed, or changed file in the current repository, I use the ga. shortcut.

alias ga.="git add ." 
Enter fullscreen mode Exit fullscreen mode

To commit the changes, I use the gc shortcut with an additional argument, the message, like so gc "My message".

# git: commit with messagefunction commitWithMessage  git commit -m $argvendalias gc=commitWithMessage 
Enter fullscreen mode Exit fullscreen mode

To edit the last commit message, I use the gcam shortcut with an additional argument, the new message, like so gcam "My new message.".

# git: commit amend messagefunction commitAmend  git commit --amend -m $argvendalias gcam=commitAmend 
Enter fullscreen mode Exit fullscreen mode

Remember to add quotation marks when using the gc and gcam shortcuts.

To view all local and remote branches, I use the gba shortcut.

alias gba="git branch -a" 
Enter fullscreen mode Exit fullscreen mode

To prune or to delete the refs to the branches that don't exist on the remote, I use the grpo shortcut.

function pruneOrigin  git remote prune origin  gbaendalias grpo=pruneOrigin 
Enter fullscreen mode Exit fullscreen mode

To fetch all remote branches, I use the gfa shortcut.

alias gfa="git fetch --all" 
Enter fullscreen mode Exit fullscreen mode

To push all local branches to remote, I use the gpa shortcut.

alias gpa="git push --all" 
Enter fullscreen mode Exit fullscreen mode

To undo all changes, I use the gr shortcut.

alias gr="git reset --hard" 
Enter fullscreen mode Exit fullscreen mode

To checkout to my master branch, I use the gcm shortcut.

alias gcm="git checkout master" 
Enter fullscreen mode Exit fullscreen mode

To pull the master branch from the remote, I use the gpom shortcut.

alias gpom="git pull origin master" 
Enter fullscreen mode Exit fullscreen mode

To create a new branch, I use the gcn shortcut with an additional argument, the branch name, like so gcn new-branch-name.

function checkoutNew  git checkout -b $argvendalias gcn=checkoutNew 
Enter fullscreen mode Exit fullscreen mode

git-flow shortcuts

I am using git-flow, a set of Git extensions that makes it easier to implement Vincent Driessen's branching model I have used for ages.

To initialize git-flow, I use the gfi shortcut.

alias gfi="git flow init" 
Enter fullscreen mode Exit fullscreen mode

To start a feature branch, I use the gfs shortcut with an additional argument, the branch name, like so gfs feature-name.

function flowFeatureStart  git flow feature start $argvendalias gfs=flowFeatureStart 
Enter fullscreen mode Exit fullscreen mode

To close and merge a feature branch, I use the gff shortcut with an additional argument, the branch name, like so gff feature-name.

function flowFeatureFinish  git flow feature finish $argvendalias gff=flowFeatureFinish 
Enter fullscreen mode Exit fullscreen mode

I use similar shortcuts to start and finish the hotfix and release branches.

Conclusion

If you want to see my complete fish configuration, I have it versioned on GitHub.

You could check my setup page to learn what other software and hardware I use.

csshtmljavascriptwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.