How can I run command in a folder without changing my current directory to it?
If you want to avoid the second cd
you can use
(cd .folder && command --key)
another_command --key
Without cd
... Not even once. I found two ways:
# Save where you are and cd to other dir
pushd .folder
command --key
# Get back where you were at the beginning.
popd
another_command --key
and second:
find . -maxdepth 1 -type d -name ".folder" -execdir command --key \;
another_command --key