Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help users run CLI commands installed in their ~/.datasette-app/venv/bin folder #92

Open
simonw opened this issue Sep 10, 2021 · 6 comments
Labels
electron-wrapper Features that go in the Node.js/Electron code research
Milestone

Comments

@simonw
Copy link
Owner

simonw commented Sep 10, 2021

As discussed on Twitter here: https://twitter.com/simonw/status/1435754909375164416

If I wanted my app to have a menu option for "Add a command to my $PATH" what are the best practices for implementing that, assuming macOS?

@simonw simonw added electron-wrapper Features that go in the Node.js/Electron code research labels Sep 10, 2021
@simonw
Copy link
Owner Author

simonw commented Sep 10, 2021

Based on that conversation, my ideal interface for this is one that shows the user a command they can run to e.g. add Datasette to their .zshrc, giving them the option to apply that themselves but also providing a "do this for me" button that makes the edit for them.

@simonw
Copy link
Owner Author

simonw commented Sep 10, 2021

An option to add sqlite-utils would be really cool too.

@simonw
Copy link
Owner Author

simonw commented Sep 10, 2021

I could add the whole of ~/.datasette-app/venv/bin to their path but I really don't want to confuse things by adding Yet Another Python to the system, which would make https://m.xkcd.com/1987/ even worse.

image

@simonw
Copy link
Owner Author

simonw commented Sep 10, 2021

That said... helping new users learn the command-line by making it easy to install twitter-to-sqlite and other tools from https://datasette.io/tools would be VERY cool.

@simonw simonw changed the title Advanced menu item for adding "datasette" binary to your path Help users run CLI commands installed in their ~/.datasette-app/venv/bin folder Sep 10, 2021
@simonw
Copy link
Owner Author

simonw commented Sep 10, 2021

https://stackoverflow.com/a/50512416/6083 has this recipe which is interesting:

osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down'

@simonw simonw added this to the 0.3.0 milestone Sep 14, 2021
@neomanic
Copy link

neomanic commented Feb 6, 2022

Looking at my own .zshrc there's not much of a standard there, and I have the following examples of different approaches:

/Applications/Postgres.app/Contents/Versions/latest/bin
/Users/josh/Library/Python/3.9/bin
"/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
# Created by `pipx` on 2021-11-08 11:13:34
export PATH="$PATH:/Users/josh/.local/bin"

I totally get the desire to make it more approachable, but given that all you have in ~/.datasette-app/ is the venv, perhaps it's viable to make /Users/josh/Library/Application Support/Datasette/venv (or the platform-preferred equivalent for future cross-platform) the default location, then everything lives together.

~/.datasette-app could be a symlink to the above... perhaps set up by a first-run option that is on by default.

That way, it can be accessible by first-timers, but then expert users have the option to limit directory sprawl.

Certainly strange sometimes being a macOS user... ha!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron-wrapper Features that go in the Node.js/Electron code research
Projects
None yet
Development

No branches or pull requests

2 participants