Share your command line shortcuts, aliases, profiles, etc

My aliases are pretty boring but I’d recommend you a few newer tools to make your way around the console much easier.

Suppose you want to quickly scan the directory you are in for a textual pattern, regardless of which file it is in. You’ll need the Rust stack, then skim and ripgrep (or the silver searcher) and then you can make an alias like this:

# If you want to use ripgrep:
alias skrg='sk --ansi -i -c "rg --color=always --line-number --ignore-case {}"'

# If you want to use the silver searcher:
alias skag='sk --ansi -i -c "ag --color {}"'

Then you get inside a project’s directory, type one of the both commands (skrg or skag) and you literally start typing the pattern you want found in any of the source files – you get instantaneous realtime feedback as you go. You can select one or many files and when you quit the tool it will output all selected files – so if you don’t want to only eyeball the results but actually feed them to another tool you can just pipe the command to something else.

This is of course a regular feature for IDEs but since I don’t use VSCode – and I still haven’t installed Spacemacs – these make my life easier.

ripgrep itself I use for several months now and I absolutely prefer it compared to grep.

I also replaced GNU/BSD’s find with Rust’s fd and I am very happy with it.

I use several other Rust tools but this comment will get way too big.

3 Likes