Linux never ceases to amaze me. I’ve been using it daily for years and somehow I haven’t come across this gem until now.
If you surround your terminal command with parentheses () then the command will execute and then return you back to your original directory.
Below I’ve got a really simple example. I’m in the folder “brackets” and I’ve created a folder “test”. I then use my parentheses around the command which moves into the test directory, creates a new file and lists the directory contents (showing the new file). Whenever the command finishes, I’m back in the folder I started in.