DEV Community

Discussion on: What are your CLI go to commands and aliases?

Collapse
 
loilo profile image
Florian Reuschel

I'm using macOS, not sure if things work in other UNIX environments (esp. pbcopy/pbpaste are macOS-specific), and some commands require external tools like Node.js or PHP to be installed.

# The prime one, can't live without it:
# Create a directory and cd to it immediately
mcd () { mkdir -p "$1" && cd "$1" }

# Copy the absolute path of the current working directory to the clipboard
# without trailing newline (e.g. to paste into quotes of a string)
here () { pwd | tr -d '\n' | pbcopy }

# Show all git tags of the current repository that represent
# valid SemVer versions
semver () { npx semver $(git tag) }

# lazygit is a great tool for quick git commits, check it out:
# https://github.com/jesseduffield/lazygit
alias lg="lazygit"

# Recursively search the current directory for PHP files
# and lint them for syntax errors
php-lint () { find . -iname "*.php" -exec php -l {} \; | grep -i "Errors.parsing" }

# Get the gzipped size (in bytes) of text in the clipboard
# (useful when writing JavaScript libraries)
gzipped () { pbpaste | gzip -c | wc -c  | sed -e 's/^[[:space:]]*//' }