mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-23 02:35:38 +01:00
docs(profiles): improved documentation
This commit is contained in:
parent
1ed17ac052
commit
1dc9e1fc90
1 changed files with 41 additions and 11 deletions
|
|
@ -1,25 +1,55 @@
|
|||
# profiles plugin
|
||||
|
||||
This plugin allows you to create separate configuration files for zsh based
|
||||
on your long hostname (including the domain).
|
||||
The `profiles` plugin allows you to automatically load machine-specific Zsh configuration files based on your fully qualified hostname.
|
||||
This is especially useful if you work across multiple systems (e.g. personal laptop, work server, containers) and need different aliases, environament variables, or behaveors on each.
|
||||
|
||||
To use it, add profiles to the plugins array of your zshrc file:
|
||||
To use it, add `profiles` to the plugins array of your zshrc file:
|
||||
|
||||
```sh
|
||||
plugins=(... profiles)
|
||||
```
|
||||
|
||||
It takes your `$HOST` variable and looks for files named according to the
|
||||
domain parts in `$ZSH_CUSTOM/profiles/` directory.
|
||||
|
||||
For example, for `HOST=host.domain.com`, it will try to load the following files,
|
||||
in this order:
|
||||
|
||||
## How It Works
|
||||
The plugin inspects the `$HOST` environament variable and attempts to source configuration files based on its domain hierarchy.
|
||||
For a hostname like:
|
||||
```bash
|
||||
HOST=host.domain.com
|
||||
```
|
||||
It fill try to source the following files in order of generality -> specificity:
|
||||
```text
|
||||
$ZSH_CUSTOM/profiles/com
|
||||
$ZSH_CUSTOM/profiles/domain.com
|
||||
$ZSH_CUSTOM/profiles/host.domain.com
|
||||
```
|
||||
Each files is sourced if it exists. More specific files override earlier general settings.
|
||||
|
||||
This means that if there are conflicting settings on those files, the one to take
|
||||
precedence will be the last applied, i.e. the one in host.domain.com.
|
||||
## Directory Structure
|
||||
Create your profile files under:
|
||||
```bash
|
||||
$ZSH_CUSTOM/profiles/
|
||||
```
|
||||
Example structure:
|
||||
```bash
|
||||
~/.oh-my-zsh/custom/
|
||||
├── plugins/
|
||||
│ └── profiles/
|
||||
│ └── profiles.plugin.zsh
|
||||
└── profiles/
|
||||
├── com
|
||||
├── domain.com
|
||||
└── host.domain.com
|
||||
```
|
||||
|
||||
## Example
|
||||
For `HOST=dev.internal.example.com`, the plugin will attempts to load:
|
||||
```bash
|
||||
$ZSH_CUSTOM/profiles/com
|
||||
$ZSH_CUSTOM/profiles/example.com
|
||||
$ZSH_CUSTOM/profiles/internal.example.com
|
||||
$ZSH_CUSTOM/profiles/dev.internal.example.com
|
||||
```
|
||||
|
||||
## Tips
|
||||
- Each profile file should contain valid Zsh code (e.g., `export`, `alias`, etc.).
|
||||
- Later (more specific) profiles override settings from earlier (more general) ones.
|
||||
- You can use this for environment-specific variables, host-specific tool paths, aliases, or functions.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue