mkdir -p ~/bin# Move individual script
mv your-script.sh ~/bin/
# Or move multiple scripts
mv script1.sh script2.sh script3.sh ~/bin/chmod +x ~/bin/*.shAdd this line to your shell configuration file:
For Bash (add to ~/.bashrc or ~/.bash_profile):
export PATH="$HOME/bin:$PATH"For Zsh (add to ~/.zshrc):
export PATH="$HOME/bin:$PATH"# For Bash
source ~/.bashrc
# or
source ~/.bash_profile
# For Zsh
source ~/.zshrcFor cleaner command names, remove the .sh extension:
cd ~/bin
mv script-name.sh script-namesudo mv your-script.sh /usr/local/bin/sudo chmod +x /usr/local/bin/your-script.shsudo mv /usr/local/bin/your-script.sh /usr/local/bin/your-scriptNote:
/usr/local/binis typically already in PATH, so no additional configuration needed.
mkdir -p ~/scripts
# or
mkdir -p ~/my-toolsmv *.sh ~/scripts/
chmod +x ~/scripts/*.shAdd to your shell configuration file:
export PATH="$HOME/scripts:$PATH"source ~/.bashrc # or ~/.zshrc- Use descriptive names:
git-fetch-allinstead offetch.sh - Remove
.shextension for cleaner commands - Use hyphens instead of underscores:
my-scriptnotmy_script
Always start your scripts with a shebang:
#!/bin/bashMake sure scripts are executable:
chmod +x script-nameTest that your script is accessible:
which script-name
script-name --helpmkdir -p ~/dotfiles/bin
cd ~/dotfiles/bin
# Move all your scripts here# Create symlinks in ~/bin pointing to your scripts repo
ln -s ~/dotfiles/bin/script-name ~/bin/script-namemkdir -p ~/bin/git-tools
mkdir -p ~/bin/dev-tools
mkdir -p ~/bin/system-tools# Create directory
mkdir -p ~/bin
# Add to PATH (choose your shell)
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc # For Bash
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc # For Zsh
# Reload configuration
source ~/.bashrc # or ~/.zshrc
# Move and setup scripts
mv your-script.sh ~/bin/your-script
chmod +x ~/bin/your-scriptCheck if everything works:
# Check if directory is in PATH
echo $PATH | grep -o ~/bin
# List all executable scripts
ls -la ~/bin
# Test script accessibility
which your-script-name- Restart terminal or run
source ~/.bashrc - Check if script is executable:
ls -la ~/bin/script-name - Verify PATH contains your directory:
echo $PATH
chmod +x ~/bin/script-name- Check script name and location
- Ensure no typos in PATH export
- Try absolute path first:
~/bin/script-name