Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

Create bash alias to run YAPI #36

Closed
IanDuncanT opened this issue Dec 21, 2018 · 7 comments
Closed

Create bash alias to run YAPI #36

IanDuncanT opened this issue Dec 21, 2018 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@IanDuncanT
Copy link
Contributor

Create aliases to run yapi instead of starting sh and running yapi.sh. Alias should be yapi. An example of the alias in use would be "yapi install test".

@IanDuncanT IanDuncanT added the enhancement New feature or request label Dec 21, 2018
@IanDuncanT IanDuncanT self-assigned this Dec 21, 2018
@Wabri
Copy link
Owner

Wabri commented Dec 22, 2018

Instead of creating an alias on bash profile, we can create a softlink in the usr/local/bin directory and name it yapi. Something like this:

sudo ln -s ~/YAPI/yapi.sh /usr/local/bin/yapi

with this you can call yapi even if you use zsh or a launcher.

@IanDuncanT
Copy link
Contributor Author

I did not know about softlinking. This would be easier and I am going to change that to run. Does this need to run on every boot or terminal startup, similar to how alias is, or does it persist across boots?

@IanDuncanT
Copy link
Contributor Author

I have tried this, however there is no change as python can't start from the softlink or alias.

@Wabri
Copy link
Owner

Wabri commented Dec 26, 2018

You're right, this is because the YAPI files used are all in a directory and the python code refers to non-absolute paths so if you even alias (or create soft link) yapi.sh (or yapi.py) when you call it outside of the yapi directory will not work because the paths are wrong.
I arrived at this by doing some tests.
First of all I changed the yapi.sh like this:

cd ~/git/YAPI
python3 ~/git/YAPI/yapi.py $1 $2

Then create the softlink and i try to run it:
hay

With these changes it works, but I dont know if this is worth it. What do you think?

@IanDuncanT
Copy link
Contributor Author

I think this is fine. If you need, you can get current path with os and append the relative path. This could help running, but your solution should work. The only question I have is if subprocess is in a new terminal and would need to cd into the correct directory.

@Wabri
Copy link
Owner

Wabri commented Dec 28, 2018

If yapi.sh have this line:
https://github.com/YetAnotherPackageInstaller/YAPI/blob/ede201b7a08efce71479ba271c458ec816fa4261/yapi.sh#L1
the problem no longer exists.

@Wabri
Copy link
Owner

Wabri commented Dec 28, 2018

Yes this is not the right method to handle this problem, but for now this is the easiest way. I will open a new issue for this new problem: "set up absolute path"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants