Skip to content

Instantly share code, notes, and snippets.

@CatChenal
Last active July 8, 2025 18:20
Show Gist options
  • Save CatChenal/039754196ea57e17a252c2c47e1167e4 to your computer and use it in GitHub Desktop.
Save CatChenal/039754196ea57e17a252c2c47e1167e4 to your computer and use it in GitHub Desktop.
Abspath in zsh
#!/bin/zsh
abs1=${0:A:h}
echo "Script dir, abs1: $abs1"
echo ""
abs2=$(cd "$(dirname "$0")" ; pwd -P)
echo "Script dir, abs2: $abs2"
echo ""
abs3=$(cd -- $(dirname -- $0) ; pwd -P);
echo "Script dir, abs3: $abs3"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment