Skip to content

Instantly share code, notes, and snippets.

@vagnerlandio
Last active April 25, 2022 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vagnerlandio/1a18abce69e9201081dc9ddb7b754cc4 to your computer and use it in GitHub Desktop.
Save vagnerlandio/1a18abce69e9201081dc9ddb7b754cc4 to your computer and use it in GitHub Desktop.
Execute command in all immediate subdirectories
#!/bin/zsh
# A simple script with a function...
mexec()
{
export THE_COMMAND=$@
find . -type d -maxdepth 1 -mindepth 1 -print0 | xargs -0 -I{} zsh -c 'cd "{}" && echo "*\033[1;32mstart {} start\033[0m*" && echo "$('$THE_COMMAND')" && echo -e "*\033[1;93mend {} end\033[0m*\n"'
}
mexec ls -al
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment