Skip to main content

6 posts tagged with "CLI"

View All Tags

Enable up-arrow history auto-complete

This how to enable up/down arrow auto-complete navigation instead of basic history navigation, without installing plugins.

Bash

nano ~/.inputrc

Paste in:

"\e[A": history-search-backward
"\e[B": history-search-forward

Run:

bind -f ~/.inputrc

Zsh

Put the following into your ~/.zshrc:

autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey '^[[A' up-line-or-beginning-search # Up arrow
bindkey '^[[B' down-line-or-beginning-search # Down arrow

Cron jobs that don't suck

To run cron jobs with your user env so that it's actually possible for them to run anything, add this to the top of your cron file (edit with crontab -e):

SHELL=/bin/bash
HOME=/home/<username>
BASH_ENV=$HOME/.bashrc

Then look at your ~/.bashrc file and make sure to remove any code (usually at the top) that exits early if found in a non-interactive shell.

Making Your Terminal Awesome

The tools we use as developers make us more effective (or at least hopefully faster) developers. So why not spend some time to make one of the most common dev tools much more useful? Here's a way to give any terminal app a personalized and awesome experience (fwiw I use the default app included with macOS). Features covered will be the following:

  • a super informative and customizable prompt
  • per-directory prompt customization
  • automatic switching of Node.js versions (easily extended to any run-time)
  • better auto complete and history
  • optional "command done" chime

Open Multiple Files in VS Code from a Grep

A simple script:

grep -rl '<search-string>' <search/dir> | xargs code -r

Between two different directories:

cd <first-path> && grep -rl '<search-string>' <search/dir> | (cd <second-path>; xargs code -r)