Symbolic Link
Create symlinks to files and directories. Will validate the targets exist before creating the link.
Syntaxโ
link:
- name: '{{ .Home }}/.aliae.yaml'
target: '{{ .Home }}/dotfiles/aliae.yaml'
- name: '{{ .Home }}/.zshrc'
target: '{{ .Env.DOTFILES }}/config/zsh/zshrc'
- name: '{{ .Home }}/Brewfile'
value: /some/location/Brewfile
if: eq .OS "darwin"
Linkโ
| Name | Type | Description |
|---|---|---|
name | string | the link name, supports templating |
target | string | the name of the file or directory to link to, supports templating |
if | string | golang template conditional statement, see if |
mkdir | boolean | create name's parent folder when it does not exist |
Expected output by shellโ
The examples below use:
link:
- name: foo
target: bar
- bash
- zsh
- fish
- pwsh
- nu
- tcsh
- xonsh
- cmd
ln -sf bar foo
ln -sf bar foo
ln -sf bar foo
New-Item -Path "foo" -ItemType SymbolicLink -Value "bar" -Force | Out-Null
ln -sf bar foo out+err>| ignore
On Windows, Nushell emits a mklink variant.
ln -sf bar foo;
ln -sf bar foo
os.execute("mklink /h foo bar > nul 2>&1")