Stop cd-ing into subdirectories just to verify the contents

Environment & Shell Customization (Aliases/Functions/.Bashrc)

Stop cd-ing into subdirectories just to verify the contents

🧩 The Challenge

Everyone does the same dance: ls, cd, ls, cd .., ls. It is a massive waste of keystrokes when you’re jumping through deep server directory structures all day.

💡 The Fix

Combine your movement and listing into one function so you see what is there the second you arrive. It saves your sanity during deep troubleshooting sessions.

cl() { cd "$1" && ls -F; }

⚙️ Why It Works

Adding this to your bashrc creates a wrapper that chains the directory change and the list command, but only executes the latter if the change actually succeeds. Bash is smart enough to stop the chain if the path you typed is garbage.

🚀 Pro-Tip: Alias this to something even shorter like ‘c’ if you really want to shave off milliseconds.

Linux Tips & Tricks | © ngelinux.com | 7/13/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted