twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.85k stars 477 forks source link

`chezmoi cd` to accept an optional path, cd into the corresponding managed path #2578

Closed RuijieYu closed 1 year ago

RuijieYu commented 1 year ago

Is your feature request related to a problem? Please describe.

Sometimes when I am deep in my configuration files (like ~/.config/zsh/path/to/subconfig/files), I would like to quickly jump to its corresponding source state under ~/.local/share/chezmoi/.... Currently chezmoi cd simply goes to the root of the git repository.

Describe the solution you'd like

$ pwd
~/.config/chezmoi
$ chezmoi cd .
% pwd
~/.local/share/chezmoi/dot_config/chezmoi
% exit
$ chezmoi cd chezmoi.toml
ERROR: not a directory
$ chezmoi cd /dev
ERROR: (outside $HOME?)
$ chezmoi cd ~/not-managed-directory
ERROR: directory not managed

I haven't thought through how symlinks should work, but this should convey the idea.

Describe alternatives you've considered

The alternative would simply be not have this feature and cd to the managed path manually.

twpayne commented 1 year ago

This is a great idea, thank you!