DEV Community

Cover image for How to execute any command from anywhere to anywhere in your laptop !
darker
darker

Posted on

2

How to execute any command from anywhere to anywhere in your laptop !

Sometimes i got in situations where i want to execute a specific command or multiple commands inside a given directory without moving there as quickly as i can !
This may sound obvious to just jump there, do the stuff and come back but as a lazy guy, i like doing that as quickly as possible and hit enter once !

target

So in this tip, you will need zoxide, a nice tool that cache all your paths by their finals dirname, that mean wherever you are in your linux system ~/zig/zag/toum/yyyy, you just have to type cd xxxx (which is here ~/boum/bam/xxx), to go there !

So this is my tip:

  • go to the target dir ($1 as the given dir)
  • execute the command ({$@:2} as all strings after the dir)
  • get back from where i was (cd -)

Image

Then add it inside your ~/.bash_aliases and you're good to go !

You can copy the source code from here !

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

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