-l /path/to/symlink ls
1. The Problem and the Symlink Use-Case
When starting new projects, I want the least amount of friction from set-up to development:
- I’ve heard of
symlink
before but never used them.- After googling, looks like a perfect use-case.
- I noticed I am reusing or updating previous functions and processes from previous projects and
- Resulting in a
tony_files
folder that I always use at initialisation (of projects).
- Resulting in a
- Rather than:
- Copying the set of tony_files manually each time to every new project,
- Then save and update all changes to these copy of files as I work on a project.
- Then copy these files to replace the original files (so I can use these updated files for the next new project)
- I can now simply create a symlink once to these original tony_files and whenever I update/save them, the originals reference files are automatically updated (removing step 2. and 3. above completely)!
2. How to Create a Symlink
2.1 Check existing Symlinks in Linux/Ubuntu (Optional):
- A symlink is represented with
->
:
2.2 Check existing Symlinks in Visual Studio Code (Optional):
- The same symlink is represented by
down-then-right-arrow
(reverse L):
2.3 Delete existing Symlinks (Optional):
/path/to/symlink rm
2.4 Create a new Symlink
-s /path/to/original/file.md /chosen/path/for/symlink/file.md ln
2.5 Check existing Symlink
See the symlink has been established again.
-l ls
3. (Bonus) Create Multiple Symlinks [Quick-Fire mode]
3.1 How-To
- Check files in working directory (wd):
ll
(If symlink existing, it wont be overriden, delete it if required) - Check files in original directory (ogdir):
ll ~/og_files
- Move files required for symlinks:
mv tony_* ~/og_files
- Check files no longer in wd:
ll
- Check files are in ogdir:
ll ~/og_files
- For Loop: create symlinks for files prefixed with
tony_
to wd:for file in ~/og_files/tony_*; do ln -s $file .; done
- Check files in wd:
ll
- Looks all good!
3.2 The Code
ll~/og_files
ll * ~/og_files
mv tony_
ll~/og_files
ll for file in ~/og_files/tony_*; do ln -s $file .; done
ll