Created
December 18, 2022 12:09
-
-
Save Sanix-Darker/27a0cb536b9c2ec7f29f93c70b942785 to your computer and use it in GitHub Desktop.
[BASH] cd and execute a command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Execute commands on a different repository and | |
# come back to where we have been ! | |
_cdex(){ | |
commandToBeExecuted="${@:2}" | |
echo "Executing => '$commandToBeExecuted' in \"$1\"" | |
# Using zoxide i can navigate to a directory just | |
# by it's name and not the full path | |
cd "$1" && $commandToBeExecuted; | |
cd - | |
} | |
alias cdex=_cdex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment