Video Lesson: Run shell commands directly from Claude Code

Run shell commands directly from Claude Code

Run Bash commands in Claude Code using shell mode with !, plus path and command autocomplete shortcuts.


Lesson Content

A common frustration I have is needing to be able to run shell commands while I have an existing Claude Code session occurring. Luckily, there's a quick shortcut to run bash commands directly from within the Claude Code terminal interface.

This is accessible within a hidden execution mode called "shell mode". Just type an exclamation mark (!), and then you can execute any bash commands right from the prompt.

Note that when you do this, it will pass the context of the results of executing that shell command back to Claude Code, and it will respond to the output of the command automatically once it lands back in the transcript.

Autocompleting paths and commands

If you try to list out directories with ls, type a space, and then tab, you're likely used to seeing an autocompletion of directories. However, you will not see this autocomplete happen in Claude Code automatically. This is because it needs to see a trigger character to act upon it.

In order to get autocomplete working, you will need prefix the argument passed to ls with either a /, ~/, or ./. So to see results as you are used to for the current directory, type:

ls ./

While within shell mode, you can also tap the up and down arrows to page through previous commands. Once you have typed a couple characters out, you can also tap the Tab key to autocomplete a previous command, but only commands which have previously been typed within this conversation while in shell mode.

Maggie

Hey, I'm Maggie! 👋

Ask me anything.

Want to chat with Maggie?

Log in for AI tutor access.

Comments

Join the discussion!

Notes

Keep track of what you learn!