Skip to content

Instantly share code, notes, and snippets.

@Sanix-Darker
Created December 18, 2022 12:09
Show Gist options
  • Save Sanix-Darker/27a0cb536b9c2ec7f29f93c70b942785 to your computer and use it in GitHub Desktop.
Save Sanix-Darker/27a0cb536b9c2ec7f29f93c70b942785 to your computer and use it in GitHub Desktop.
[BASH] cd and execute a command
#!/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