Skip to content

Instantly share code, notes, and snippets.

@idrisr
Created September 4, 2021 14:57
Show Gist options
  • Select an option

  • Save idrisr/fc5e8edc658e8f4da71dbc5aeb919717 to your computer and use it in GitHub Desktop.

Select an option

Save idrisr/fc5e8edc658e8f4da71dbc5aeb919717 to your computer and use it in GitHub Desktop.
# take from the book Python for DevOps, https://www.amazon.com/Python-DevOps-Ruthlessly-Effective-Automation/dp/149205769X
cdp () {
dir=$(python3 -c """
from pathlib import Path
try:
import ${1} as _
print(Path(_.__file__).parent)
except Exception as e:
print(e)
""")
cd $dir
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment