A cross-platform implementation that works in bash, PowerShell and cmd, inspired by the ZSH take command. (utterly copied)
- Creates and changes into directories in one command
- Supports nested directory creation
- Handles git repository cloning
- Downloads and extracts archives (tar.gz, tgz, tar.bz2, tar.xz, zip)
- Works with relative and absolute paths
- Supports Unicode and special characters
- Handles home directory (
~) expansion - Platform-aware path handling
- Git repository support (HTTPS/SSH)
Add to your .bashrc:
curl -o- https://raw.githubusercontent.com/deblasis/take/main/scripts/install.sh | bashOr manually add to your .bashrc:
take() {
if [ -z "$1" ]; then
echo "Usage: take <directory|git-url|archive-url>" >&2
return 1
fi
take_result=$(take-cli "$1")
if [ $? -eq 0 ]; then
cd "$take_result"
else
echo "$take_result" >&2
return 1
fi
}iwr https://raw.githubusercontent.com/deblasis/take/main/scripts/install.ps1 -useb | iexOr manually add to your PowerShell profile:
function Take {
param([string]$Path)
if (-not $Path) {
Write-Error "Usage: Take <directory|git-url|archive-url>"
return
}
$result = take-cli $Path
if ($LASTEXITCODE -eq 0) {
Set-Location $result
} else {
Write-Error $result
}
}# Create single directory
take mynewdir
# Create nested directories
take path/to/new/dir
# Use absolute paths
take /absolute/path/to/dir
# Use home directory
take ~/new/dir# Clone via HTTPS
take https://github.com/user/repo.git
# Clone via SSH
take [email protected]:user/repo.git
# Shallow clone
take -depth 1 https://github.com/user/repo.git# Extract tar archives
take https://example.com/archive.tar.gz
take https://example.com/archive.tgz
take https://example.com/archive.tar.bz2
take https://example.com/archive.tar.xz
# Extract ZIP archives
take https://example.com/archive.zip-depth N Git clone depth (0 for full clone)
-force Force operation even if directory exists
-version Show version information
go build ./cmd/takego test ./...- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.