-
Notifications
You must be signed in to change notification settings - Fork 227
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
Utility folder for store commonly used helper functions #5
Comments
Maybe make stash a package. The downside to this is that it adds an extra dependency to commands that could otherwise run standalone as well. Perhaps stash could automatically collapse all "long" paths when writing to the output (configurable of course in case it should cause problems) so the commands don't need to do tilde collapsing on their own every time they write a path. |
PS - there's a def collapseuser(path):
"""Reverse of os.path.expanduser: return path relative to ~, if
such representation is meaningful. If path is not ~ or a
subdirectory, the absolute path will be returned.
"""
path = os.path.abspath(unicode(path))
home = os.path.expanduser("~")
if os.path.exists(os.path.expanduser("~/Pythonista.app")):
althome = os.path.dirname(os.path.realpath(os.path.expanduser("~/Pythonista.app")))
else:
althome = home
if path.startswith(home):
collapsed = os.path.relpath(path, home)
elif path.startswith(althome):
collapsed = os.path.relpath(path, althome)
else:
collapsed = path
##print(path, home, althome, collapsed)
return "~" if collapsed == "." else os.path.join("~", collapsed) |
@dgelessus Thanks for the advices. I am also still thinking about the best approach to do this. I am kinda reluctant to make it an inherent part of StaSh. My personal feel is that the shell really is not in the position to change outputs generated by external scripts. The shell manages screen display issues like scroll and refresh, but the actual contents should only be managed by external scripts. So I thought about creating a sub-folder (similar concept as the Your |
Added a |
I plan to make some changes on how Python files under The reason of the changes are:
|
The changes now are committed 0322f3b Both |
Merge pull request #408 from onyxware/dev
For an example, un-expanduser is a common need by many other programs like
pwd
,ls
, etc.The text was updated successfully, but these errors were encountered: