xxh / xxh-plugin-zsh-ohmyzsh

Oh my zsh plugin for xxh zsh
BSD 2-Clause "Simplified" License
38 stars 20 forks source link

Support $ZSH_CUSTOM location #4

Closed SeerLite closed 4 years ago

SeerLite commented 4 years ago

Is your feature request related to a problem? Please describe. I have ZSH_CUSTOM set up in my .zshrc. It's only to load a custom theme I use. However, since this directory isn't copied over to the remote then sourcing .zshrc fails and xxh doesn't really have any of my local configurations.

Describe the solution you'd like Seamless mode also copies this folder over to the remote. I'm not sure of how paths are set up for themes and configs but I think this shouldn't be too hard to set up.

And thank you, this tool is amazing.

For community: ⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

SeerLite commented 4 years ago

Whoops. Looks like the default location for it is copied over, just not the one defined in $ZSH_CUSTOM. So I guess the feature request changes to "support custom location for ZSH_CUSTOM".

Edit: Official info about ZSH_CUSTOM i guess

anki-code commented 4 years ago

Hello @SeerLite! Thank you for this case and sorry for the delay. I'm not the user of ZSH_CUSTOM but I can try to help.

As I understand we have a directory with your custom scripts and we should upload it to host and then set the ZSH_CUSTOM environment variable to load it.

Let's do this:

  1. Fork the xxh-plugin-prerun-dotfiles and rename to xxh-plugin-prerun-dotfiles-SeerLite.
  2. Take a look to the README :)
  3. Put your custom_zsh_direcotry to the home directory in the repo.
  4. Add export ZSH_CUSTOM=$XXH_HOME/custom_zsh_direcotry to the end of 100-prerun.sh.
  5. Install your plugin to xxh and try to connect:
    xxh +I https://github.com/SeerLite/xxh-plugin-prerun-dotfiles-SeerLite
    xxh myhost

    In case of not working or errors check the paths in $XXH_HOME and $ZSH_CUSTOM and back here with details.

SeerLite commented 4 years ago

Oh wow that's a lot of changes this project's been through huh :o Thank you for looking into this, and sorry for my delay too

I'm not sure I understood exactly what I have to do. Do I have to upload my ZSH_CUSTOM dir to my fork of xxh-plugin-prerun-dotfiles on GitHub? Is there not any way to do this locally (like changing some variables)? Or is this just a way to test things out?

Also, I was just about to be trying out xonsh, possibly even switching to it from zsh. So I'm not sure if this is relevant to me anymore. I'll still try to go through with it if I find it's easy enough.

anki-code commented 4 years ago

Do I have to upload my ZSH_CUSTOM dir to my fork of xxh-plugin-prerun-dotfiles on GitHub? Is there not any way to do this locally (like changing some variables)? Or is this just a way to test things out?

Public repo allows me to review the source code or repeat the errors but if you want to keep your custom files privately you can avoid creating public repo and do everything in the local directory:

# bash or xonsh

mkdir /tmp/xxh_dev && cd /tmp/xxh_dev
git clone https://github.com/xxh/xxh-plugin-prerun-dotfiles xxh-plugin-prerun-dotfiles-SeerLite
cd xxh-plugin-prerun-dotfiles-SeerLite

# change the path and the name of your directory
cp /PATH/TO/YOUR_CUSTOM_DIR home/  
echo 'export ZSH_CUSTOM=$XXH_HOME/YOUR_CUSTOM_DIR' >> 100-prerun.sh

# before this you already have xxh-plugin-zsh-ohmyzsh installed
xxh +RI xxh-plugin-prerun-dotfiles-SeerLite+path+/tmp/xxh_dev/xxh-plugin-prerun-dotfiles-SeerLite
xxh myhost +if

Also, I was just about to be trying out xonsh, possibly even switching to it from zsh. So I'm not sure if this is relevant to me anymore. I'll still try to go through with it if I find it's easy enough.

Glad to hear this! Feel free to share the questions and feedback about your xonsh experience in xonsh issues or in chat!

SeerLite commented 4 years ago

Hey! Sorry for the delay again! It's working perfectly! Seriously, thank you so much, I really love this project!

I didn't need to add anything to 100-prerun.sh. I'm already exporting $ZSH_CUSTOMto $HOME/.zsh_custom in .zshrc, and that in turn becomes $XXH_HOME/.zsh_custom.

Edit 3: I actually did add the exporting to 100-prerun.sh. It's just that I then removed it (from some file in .xxh/.xxh/) and thought it worked anyway. I understand how xxh works now (I thought the oh-my-zsh plugin copied .zshrc too, turns out it doesn't). Feel free to ignore anything I said below, I was coming up with an idea that won't work with the way the oh-my-zsh plugin works. Sorry about that :S


Before anything, I want to say that I don't know much about the codebase and how xxh is organized. I remember skimming the readme the first time I tried it out and then moved on and forgot about it. But I've been messing around with this plugin for a while now, and I think I understand how it works. I have a few questions:

  1. I noticed plugins get installed in ~/.xxh/.xxh/plugins/. Is it a bad idea to edit the xxh-plugin-prerun-dotfiles files in there directly, instead of reinstalling the plugin?
  2. If it's okay to edit it directly, what do you think of copying files sourced from .zshrc over there in .zshrc itself? I'm thinking something like:
if [[ -d $HOME/.xxh/.xxh/plugins/xxh-plugin-prerun-dotfiles/ ]]; then
    cp -rf $HOME/.zsh_aliases $HOME/.xxh/.xxh/plugins/xxh-plugin-prerun-dotfiles/home/
fi

I think this could be used to make the installation/usage of this plugin a bit simpler, without requiring any manual copying (well, aside from .zshrc, of course).

Edit: I just realized my awesome idea doesn't work. I need to understand more of how xxh works :S. Still, what are your thoughts on a process like that one? Edit 2: Alright, I'm stupid. Turns out xxh-plugin-zsh-ohmyzsh doesn't actually copy .zshrc at all, and only downloads the default oh-my-zsh config. I wonder why the theme works fine without editing prerun then...

anki-code commented 4 years ago

I don't know much about the codebase and how xxh is organized.

Detailed workflow - https://github.com/xxh/xxh/wiki#detailed-workflow-with-code

directly, instead of reinstalling the plugin?

It's ok for development process. Just don't forget that next +RI <plugin> removes the plugin directory and you lose your changes. And also add +if to xxh when connect to update changed files.

If it's okay to edit it directly, what do you think of copying files sourced from .zshrc over there in .zshrc itself

It looks like what done in xxh-plugin-zsh-zshrc where Roman breaks the "careful principle" and just make a blindfold copying the files from local home :) If you plan to publish your solution just make a disclaimer as Roman :)

PS: If you like the idea of xxh spread the word about the project :) Tweet, share, etc :)

SeerLite commented 4 years ago

I understand how it all works now. I made this issue with the wrong idea: I thought .zshrc was copied automatically. xxh-plugin-zsh-zshrc looks exactly like what I had in mind. But now that I know more about this all, I think I'll be going with the xxh-plugin-prerun-dotfiles route. Thank you so much for explaining it to me!

I think I can close this issue now.