clone is an extremely simple bash script that does two things:
- It clones Git repositories in a consistent directory hierarchy.
clone git@github.com:octocat/Spoon-Knife.git
clone https://git.sr.ht/~sircmpwn/git.sr.ht
tree ~/Clones
# ~/Clones
# ├── git.sr.ht
# │ └── sircmpwn
# │ └── git.sr.ht
# └── github.com
# └── octocat
# └── Spoon-Knife- It adds the cloned repository to
autojump, if installed.
clone git@github.com:octocat/Spoon-Knife.git
j spoon
# ~/Clones/github.com/octocat/Spoon-Knifecurl -Lo ~/.local/bin/clone \
https://github.com/maxmouchet/clone/releases/latest/download/clone
chmod +x ~/.local/bin/clone
mkdir -p ~/Clones # Or specify another directory, see below.clone [git-clone-options] <repository>By default clone uses the ~/Clones directory. Use the CLONE_BASE_DIR environment variable to specify another directory:
export CLONE_BASE_DIR=/tmp/clones
clone git@github.com:octocat/Spoon-Knife.git
# Cloning into '/tmp/clones/github.com/octocat/Spoon-Knife'...
If you encounter an error when executing the curl command to install clone, it may be due to ~/.local/bin not existing on your system or not being included in your PATH. Follow the steps below to resolve these issues:
If ~/.local/bin does not exist on your system, create it using:
mkdir -p ~/.local/binThis directory is used by clone to store executable scripts and should be included in your system's PATH for easy access.
To make sure executables in ~/.local/bin are accessible from any terminal session, you'll need to add this directory to your PATH. You can do this by appending the following line to your shell's configuration file (e.g., ~/.bashrc, ~/.zshrc, etc.):
export PATH="$HOME/.local/bin:$PATH"After adding the line, reload your shell configuration to apply the changes:
source ~/.bashrc # Or the relevant file for your shell, such as .zshrcBy following these steps, you should be able to successfully run the curl command to install clone and execute it from any location in your terminal.