Skip to content

Instantly share code, notes, and snippets.

@kitzberger
Created August 12, 2025 07:09
Show Gist options
  • Select an option

  • Save kitzberger/704732fb2cf3b8b11d36b9de45dd4123 to your computer and use it in GitHub Desktop.

Select an option

Save kitzberger/704732fb2cf3b8b11d36b9de45dd4123 to your computer and use it in GitHub Desktop.
Current directory in bash
#!/bin/bash
# Current scripts folder (incl. resolving symlinks)
SCRIPT_DIR="$( cd -P "$( dirname "$( readlink -f "${BASH_SOURCE[0]}" )" )" && pwd )"
echo "This script lives in $SCRIPT_DIR and doesn't care from where you run it!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment