If my .zshrc file is ~/.dotfiles/zsh/.zshrc, how can I create a symlink so that the file appears as ~/.zshrc?
The cd
step in Alexej's answer isn't needed as you can call ln -s target destination explicitly.
ln -s ~/.dotfiles/zsh/.zshrc ~/.zshrc
run:
cd ~/ ; ln -s ~/.dotfiles/zsh/.zshrc
cd ~
--and try running this from there ln -s ~/.dotfiles/zsh/.zshrc
–
Plasmolysis ln
doesn't have the -T
option, my bad. I'll edit my answer. –
Plasmolysis for me, when using relative path for symlink, it can show error: ~/.zshrc: No such file or directory error
as @astephen2. You should change to absolute path then it working fine
On MacOS, you can't use ~
in a symlink where the directory is quoted. You need to use full paths. I'd recommend running ln -s "$HOME/.dotfiles/zsh/.zshrc" "$HOME/.zshrc"
Alternatively, you can forget the quotes, and use ~
in place of $HOME
, however if there are any spaces (or variables with spaces) you'll probably run into problems.
~
in the arguments to ln -s
, though; the shell expands them before ln
is executed. –
Arundel ~
–
Phifer ~
unquoted: ~/"$SOMEDIR"/.zshrc
expands correctly. –
Arundel You don't actually need a symlink. Add the following to ~/.zshenv
:
ZDOTDIR=~/.dotfiles/zsh
zsh
sources ~/.zshenv
before any other files, and will use the value of $ZDOTDIR
as the location for local configuration files in lieu of your home directory.
© 2022 - 2024 — McMap. All rights reserved.