Jaykul / dotfiles

Using chezmoi to manage dotfiles (including my PowerShell profile)
5 stars 1 forks source link

[Question] - OneDrive And `$PROFILE` Config #1

Open mattcargile opened 1 year ago

mattcargile commented 1 year ago

Hey Jaykul -

Just getting into chezmoi and I was perusing your files. I see you make reference to OneDrive. How are you handling that? Are you doing chezmoi --destination ~\OneDrive as your root? Or are you actually using symbolic links instead?

Additionally, how are you creating your $PROFILE? Is that another link or do you just dot-source the chezmoi profile template?

So I see the below file which puts some of the pieces together. I assume there is code elsewhere to create the symlink?

https://github.com/Jaykul/dotfiles/blob/master/dot_config/powershell/run_after_symlink.ps1

Jaykul commented 11 months ago

OneDrive is a royal pain. I'm using an "Enterprise" OneDrive (even at home), rather than a personal one, so not only is it redirecting my Documents, etc., it's actually putting "OneDrive - CompanyName" in the path ... with SPACES in the folder name that just make everything difficult.

You are correct though, the run_after_symlink.ps1 script is the magic.

There actually isn't a symlink at all. Even though I chose that name for the file, I ended up deciding to just copy the profile multiple times. Creating symlinks on Windows requires elevation, and is not necessary.

The important thing is:

  1. The name needs to be "run_after_something.ps1" which makes chezmoi run it, instead of copying it.
  2. It uses $Env:OneDriveCommercial to find the right location. If you're using personal OneDrive, you can use $Env:OneDrive.
  3. You could switch to "runonchange" if you changed it to a .tmpl file. The go-template snippet # profile hash: {{ include "profile.ps1" | sha256sum }} would ensure that this file would change whenever the profile.ps1 file changes... but I decided that I wanted to always overwrite the profile ... since we can't tell if the copies have been messed with ;-)

Some of the stuff that I was trying to make happen when I did that ended up not working (i.e. I was hoping powershell.config.json would let me configure where PowerShell searches for it's profile, but that has never been implemented by Microsoft).