Skip to content

Instantly share code, notes, and snippets.

@MalteT
Created November 24, 2020 09:16
Show Gist options
  • Select an option

  • Save MalteT/9e0ee9ce63912ebfbe0cbc9c7e6c01dc to your computer and use it in GitHub Desktop.

Select an option

Save MalteT/9e0ee9ce63912ebfbe0cbc9c7e6c01dc to your computer and use it in GitHub Desktop.
#!/bin/sh
# Auto cd into sub-dirs as long as it's the only file in a directory
function deepcd {
cd $1
if [ $(ls -l | wc -l) -eq 2 ]; then
only_thing_here=$(ls)
if [ -d "$only_thing_here" ]; then
deepcd "$only_thing_here"
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment