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

Personal Cheatsheets #97

Open
dufferzafar opened this issue Aug 11, 2018 · 19 comments
Open

Personal Cheatsheets #97

dufferzafar opened this issue Aug 11, 2018 · 19 comments

Comments

@dufferzafar
Copy link

Is there a way to create personal / private cheatsheets? for tools that are internal to our team etc.

With other tools like Chris' cheat we could do this by simply adding a file in one of the config directories.

How can this be done using the cht.sh bash CLI tool?

@chubin
Copy link
Owner

chubin commented Aug 12, 2018

The first and main question is can you install the cheat.sh server somewhere in your local environment or not?

If yes, then it is not a problem at all. With our "cascading cheat sheets" mode (it will be described in README.md soon), you can create a hierarchy of cheat sheets servers, where each server delivers local cheat sheets + if a requested cheat sheet is not found, the query is forwarded to the upstream server (and so on).

cheat.sh
    ^
    |
cheat.my
    ^
    |
clients

For the user it looks fully transparent, it uses the same clients as always. The only difference is that the clients should be configured the correct server (is some clients are used; of course, if you use nothing but curl, you change nothing but the name of the server in the query):

curl cheat.my/secret

In this query, you ask the cheat.my server for the secret cheat sheet.

@chubin chubin mentioned this issue Aug 12, 2018
9 tasks
@dufferzafar
Copy link
Author

dufferzafar commented Aug 15, 2018

Um, I can install whatever I want on my personal machine. But not too sure about the work machine I use. It has all sorts of weird permission restrictions.

Is there any other alternative?

I used to use my own cheat tool before, and it just needed a list of paths where cheats were kept. So I would give it the path to cheatsheets from chrisallenlane/cheat and my own secret cheats.

Could something like this directory list be added to the cht.sh CLI?

  1. First check if file /path/to/secret/command exist
  2. Else, do curl cht.sh/command

@chubin
Copy link
Owner

chubin commented Aug 15, 2018

@dufferzafar It is an interesting idea, but this solution would be inconsistent, because the cheat sheets would be available only on the local machine and only for this client. Is it ok for you?

@dufferzafar
Copy link
Author

dufferzafar commented Aug 15, 2018 via email

@chubin
Copy link
Owner

chubin commented Aug 16, 2018

Yes, you are absolutely right, but for that we have to fully implement the cascading cheat sheets feature.
It is almost done, and I think you could use it soon

@miloskroulik
Copy link

Any news regarding this?

@chubin
Copy link
Owner

chubin commented Dec 29, 2019

@miloskroulik Please take a look at this, starting here:

#98 (comment)

You can install cheat.sh in the standalone mode, and configure it to use your own
cheat sheets sources. Is it the feature you are looking for?

@ochaloup
Copy link

@chubin I'm trying to understand how to configure my own cheat sheets source but unfortunately I haven't found how to do it.

I installed the cht.sh in standalone mode and the installation says that

You can add your own cheat sheets repository (config is in `etc/config.yaml`),
or create new cheat sheet adapters (in `lib/adapters`).

The etc/config.yaml contains just information about redis cache

server:
    address: "0.0.0.0"
cache:
    type:   redis

I can't find any information about this configuration file and what can be configured.

I'm trying to do this for my own dev machine. The best I would like not to start a "server", but just define a directory where the text resides - ie. #97 (comment).

I found if I add a file under some directory of upstream folder - e.g. upstream/cheatsheets/my-cheat-sheet then the file will be considered (using cht.ch command). But I don't think it's the expected usage and it's not optimal.

The other option could probably be (?) to add a ~/.cheat.sh/lib/ adapter - as a .py source (e.g. similar to https://github.com/chubin/cheat.sh/blob/master/lib/adapter/cheat_sheets.py) that would work with a repository and somehow register(?) it to cht.ch?

Would you be so kind and help me what is the best practice? Is there some doc about these topics?
Thanks a lot

@ochaloup
Copy link

Oh, I probably found it. Is it the feature which is under development, right?
#230

@chubin
Copy link
Owner

chubin commented Nov 11, 2020

@ochaloup actually, you did it right.
The easiest way to do it would be exactly as you did:
you can just replace the repository URL here:

https://github.com/chubin/cheat.sh/blob/master/lib/adapter/cheat_sheets.py#L47

What structure has your internal cheat sheets repository?
The same as https://github.com/chubin/cheat.sheets ?

@ochaloup
Copy link

ochaloup commented Nov 12, 2020

@chubin thanks a lot for answering

On testing this I ended with trying to create an adapter working with the file system and now I have several more questions :-)
ochaloup@dbab084

On playing with the code I stuck with not understanding of the config setup. The code was placed at the lib directory but the adapter searched no page. Then I found there is a list adapters.active and routing.main(...?)

"adapters.active": [

Is there some way to update the config.yaml to get those list updated (ie. appended) with one more adapter?

Btw. what is the place where the config.yaml can be placed? I run on Fedora 32 and the config is under ~/.cheat.sh/etc/config.yaml. I don't understand if changes of the code under the directory will make working commands like cheat.sh --shell; update (I was thinking there could be some git pull in the background and conflicts may occur. But in fact even there are some changes at the cheat.sh master/origin no code update seems not happen. I'm thinking if because of the conflicts. On the other hand there are no errors shown)
Maybe the under ~/.cht.sh/config.yaml?

@ochaloup
Copy link

hi @chubin , I don't want to bother you with long questions. Just if you find time to explain details how to work correctly with adapters (ie. my doubts above) or/and what is the plan about easy ways to add personal cheatsheets it would be great. Thank you.

@chubin
Copy link
Owner

chubin commented Nov 29, 2020

@ochaloup Hi! Please excuse me for the long response time, I hope it will be better in future.

You are doing everything absolutely right!
I like your file based implementation, and this approach will work.

I don't know though why you don't want to use an existing, Git-based adapter,
because even for private notes, git is a useful thing to have. You could just
create a git repository (even a private one) for your notes, and just use it.

Location of the config file is etc/config.yaml as you correctly guessed,
and you can configure the routing table directly in it.

Have you added your adapter to adapters.active + to the route table (routing.main)?

@ochaloup
Copy link

@chubin thanks for the response and I do apologize for my late response as well.
I was playing with my own repository back in the time and but I haven't got to finish it with your guidelines.

On the lib/config.py - I added my adapter to adapters.active and routing.main. The cheet.sh is capable to list the cheetsheets but there is not working the TAB autocomplete functionality in bash. I will be missing some setup here. Would you have tip for me? :-)

I agree that git-based adapter could be working fine just I'm not used to work with git as a storage for my notes. Thus I decided to adjust your great tool for my purposes. I understand that it's not your use case but for me it's fine to not be forced to use the github.
By interest, would you consider adding a functionality of non git-based adapters in future or rather not?

If you don't mind my asking - or I can post to some other place if this is not appropriate for such kind of question - how does work the command cht.sh update? Should there be update of repositories or the cheat.sh scripts from github? It seems it does nothing for me.

@dufferzafar
Copy link
Author

So, I needed a personal cheatsheet again and came back to this.

@chubin you'd mentioned:

we have to fully implement the cascading cheat sheets feature

was this done?

@chubin
Copy link
Owner

chubin commented Dec 28, 2020

@ochaloup

The cheet.sh is capable to list the cheetsheets but there is not working the TAB autocomplete functionality in bash. I will be missing some setup here. Would you have tip for me? :-)

If you see that the new cheat sheets are available when you curl your server directly, but you don't see them with the cht.sh client, can you please make sure that it access your server, and not the main cheat.sh server?

By interest, would you consider adding a functionality of non git-based adapters in future or rather not?

Yes, absolutely. What type of the adapter do you need?

how does work the command cht.sh update

It updates the cht.sh client itself, if it needs to be updated.

@dufferzafar Yes this was implemented. It is not yet fully documented, but it is implemented
and it works

@ochaloup
Copy link

ochaloup commented Jan 4, 2021

@chubin thanks for the answers

ad autocomplete functionality) ok, then it's the point. I haven't started local server (at least I think so) and I didn't know that the autocompletion is queried via a remote call. I assume the reason is that the main cheat.sh server is queried for me.

ad non git-based adapters) I would like to have a chance to use just the file based repo - ie. point to a directory where cheat sheets are placed (no new adapters to be created or configured, just one configuration line pointing to a directory). That was the point of my question - if this is possible in future?

ad cht.sh update) ok, I see. I figured out that I was thinking that the repositories should be updated but that's what should be done with ~/.cheat.sh/ve/bin/python3 ~/.cheat.sh/lib/fetch.py update-all.
I will need to investigate on cht.sh --standalone-install to see how this will work for me (I'm still using what was available 2 months ago where offline_usage branch was not working).

@chubin
Copy link
Owner

chubin commented Jan 5, 2021

file based adapter; if this is possible in future?

Yes, absolutely

2 months ago where offline_usage branch was not working

I believe the branch was merged more than two months ago;
maybe there were some minor fixes two months ago, but nothing big.
I would suggest you to try to go through this documentation,
and check if it works for you or not

https://github.com/chubin/cheat.sh/blob/master/doc/standalone.md

@ochaloup
Copy link

ochaloup commented Jan 6, 2021

@chubin oh, I see the offlne branch is merged, right? I was confused as the image at [https://github.com/chubin/cheat.sh/blob/master/doc/standalone.md]standalone.md) (ie. https://user-images.githubusercontent.com/3875145/57986904-ef3f1b80-7a7a-11e9-9531-ef37ec74b03a.png) mentions the tracking branch offline_usage. I will work with master then.

grayed pushed a commit to grayed/cheat.sh that referenced this issue Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants