mfhepp / cdf Goto Github PK
View Code? Open in Web Editor NEWcdf: Change to favorite directories in Bash
Home Page: https://mfhepp.github.io/cdf/
License: MIT License
cdf: Change to favorite directories in Bash
Home Page: https://mfhepp.github.io/cdf/
License: MIT License
In order to avoid redundant bookmarks, it would be good if you check all bookmarks for identical link targets to PWD.
One may then offer to rename the existing shortcut or to abort.
Basically just loop over all links in the shortcuts folder and check if their realpath matches $PWD.
The code could be improved to be more consistent and more portable (mostly ChatGPT 4 recommendations):
echo
vs. printf
."$PWD"
instead of $PWD
etc.realpath
and ln
Commands for Portability: The realpath
and ln
commands might not be available or behave differently on some systems. You can write a function to manually resolve real paths or use readlink as an alternative. Similarly, for ln, check if the command exists and handle errors.cd
Command Failure: The cd command can fail (e.g., due to permission issues). Always check its exit status to ensure the subsequent commands operate in the correct directory.zsh
and other Non-Bash shells.Currently, the list of shortcuts for autocompletion is updated only when you either open new terminal or reload the shell profile.
It would be better to update the list of shortcuts when a new entry is added or an existing entry has been removed.
The code should basically be portable as it stands; the tests run at least with zsh 5.9
on OSX. The only required changes for official support would be
complete
is not available in zsh
and the function might also not work as it stands. A minimal solution would be no autocomplete in zsh..zshrc
etc. to the installation script, observing potential differences between OSX and Linux..bashrc
vs. .bash_profile
in the installer - clarifying where to put the functions best.Useful resources:
The symbolic links will break if the link target has been deleted or moved. It would be good to
cdf NAME
if the target does not existrm
:-(--list
Caveats and considerations:
cdf --remove foo
addfav --remove foo
cdf
command, like
cdf foo
cdf --add foo
cdf --list
cdf --remove foo
cdf --remove --broken
AFAIK, there is no easy way to fix broken symbolic links automatically, as OSX Aliases would do.
It may be useful to add automatic installation for ZSH to the installer.
Blockers:
.zshrc
or .bashrc
is no reliable indicator of the proper shell, as it may have to be created..bashrc
vs .bash_profile
on OSX).A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.