DEV Community

Bartosz Maciejewicz
Bartosz Maciejewicz

Posted on

3 3

Bash aliases to back in terminal with optional show file list preview.

Hey my name is Bart. I would like to share with one of my bash aliases!

I really like automate every repetitive work and reduce the steps required to do a work, so in this example I'll show you how to reduce amount of pressed keys to back e.g. 3 times.

Instead of:

cd ../../..
Enter fullscreen mode Exit fullscreen mode

Just write 3 signs using this alias:

..3
Enter fullscreen mode Exit fullscreen mode

If you want back and see a list then just add one more dot.

In case you want to back 10 times then use ..5 twice :)

  • .. is go back
  • ... is go back and show a list of directories
  • 5 is example amount steps to back. TIP: you can count / signs in directory
alias ..='cd ..'
alias ..1='cd ..'
alias ..2='cd ../..'
alias ..3='cd ../../..'
alias ..4='cd ../../../..'
alias ..5='cd ../../../../..'
alias ...='cd .. && ll'
alias ...1='cd .. && ll'
alias ...2='cd ../.. && ll'
alias ...3='cd ../../.. && ll'
alias ...4='cd ../../../.. && ll'
alias ...5='cd ../../../../.. && ll'
Enter fullscreen mode Exit fullscreen mode

I hope that this alias will be useful for you too.

I have more much more interesting aliases. I just wanted to write first post with really simple example.

Let me know in the comment if you like it and if I should share with you some next aliases ideas or automate tips :)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more