Bash aliases and scripts documentation.
This commit is contained in:
parent
b72402e452
commit
cd087cd73a
148
docs/Bash.md
Normal file
148
docs/Bash.md
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
# Bash Aliases & Scripts
|
||||||
|
|
||||||
|
## Navigation
|
||||||
|
|
||||||
|
* *..* → cd ..
|
||||||
|
|
||||||
|
* *...* → cd ../..
|
||||||
|
|
||||||
|
* *....* → cd ../../..
|
||||||
|
|
||||||
|
* *.....* → cd ../../../..
|
||||||
|
|
||||||
|
* *~* → cd ~
|
||||||
|
|
||||||
|
* *-* → cd -
|
||||||
|
|
||||||
|
|
||||||
|
## Shortcuts
|
||||||
|
|
||||||
|
* *dr* → cd ~/Dropbox
|
||||||
|
|
||||||
|
* *pj* → cd ~/Dropbox/Projects
|
||||||
|
|
||||||
|
* *pjr* → cd ~/Dropbox/Projects/_Repos
|
||||||
|
|
||||||
|
* *pjf* → cd ~/Dropbox/Projects/_Forks
|
||||||
|
|
||||||
|
* *pjm* → cd ~/Dropbox/Projects/!
|
||||||
|
|
||||||
|
* *o* → open
|
||||||
|
|
||||||
|
* *oo* → open .
|
||||||
|
|
||||||
|
* *marked* → open -a marked
|
||||||
|
|
||||||
|
* *md <dir>* → Make directory and `cd` to it.
|
||||||
|
|
||||||
|
* *f <what>* → Recursively find file in current directory.
|
||||||
|
|
||||||
|
* *c* → Trim new lines and copy text to clipboard.
|
||||||
|
|
||||||
|
|
||||||
|
## File System
|
||||||
|
|
||||||
|
### extract <filepath> [directory]
|
||||||
|
|
||||||
|
Extract archives of various types.
|
||||||
|
|
||||||
|
### emptytrash
|
||||||
|
|
||||||
|
Empty the Trash on all mounted volumes and the main HDD. Also, clear Apple’s System Logs to improve shell startup speed.
|
||||||
|
|
||||||
|
### show / hide
|
||||||
|
|
||||||
|
Show/hide hidden files in Finder.
|
||||||
|
|
||||||
|
|
||||||
|
## Text
|
||||||
|
|
||||||
|
### dos2unix <filepath>
|
||||||
|
|
||||||
|
Convert file to Unix line endings.
|
||||||
|
|
||||||
|
### crlf [--force]
|
||||||
|
|
||||||
|
Find files with Windows line endings (and convert them to Unix when `--force` key given).
|
||||||
|
|
||||||
|
### escape <characters>
|
||||||
|
|
||||||
|
Escape UTF-8 characters into their 3-byte format: `£` → `\xC2\xA3`.
|
||||||
|
|
||||||
|
### codepoint <character>
|
||||||
|
|
||||||
|
Get a character’s Unicode code point: `£` → `\x00A3`.
|
||||||
|
|
||||||
|
|
||||||
|
## Network
|
||||||
|
|
||||||
|
### GET / HEAD / POST / PUT / DELETE / TRACE / OPTIONS <URL>
|
||||||
|
|
||||||
|
Make HTTP request using respective method.
|
||||||
|
|
||||||
|
### gz <filepath>
|
||||||
|
|
||||||
|
Get gzipped file size.
|
||||||
|
|
||||||
|
### httpcompression <URL>
|
||||||
|
|
||||||
|
Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL. Send a fake UA string for sites that sniff it instead of using the Accept-Encoding header.
|
||||||
|
|
||||||
|
### add-ssh-host <username> <hostname> <identifier>
|
||||||
|
|
||||||
|
Create an SSH key and uploads it to the given host.
|
||||||
|
|
||||||
|
### yay
|
||||||
|
|
||||||
|
Upload current directory to special directory on my hosting.
|
||||||
|
|
||||||
|
|
||||||
|
## NPM
|
||||||
|
|
||||||
|
### npm-patch / npm-release
|
||||||
|
|
||||||
|
Increment version (`npm-patch` by 0.0.1 and `npm-release` by 0.1.x) of NPM package and make Git commit.
|
||||||
|
|
||||||
|
|
||||||
|
## Grunt
|
||||||
|
|
||||||
|
### gw / gs
|
||||||
|
|
||||||
|
Run Grunt’s watch and server tasks:
|
||||||
|
|
||||||
|
gw → grunt deploy --debug && grunt watch --debug
|
||||||
|
gs → grunt deploy --debug && grunt serve --debug
|
||||||
|
|
||||||
|
### gi [template]
|
||||||
|
|
||||||
|
Just shortcut for `grunt-init`.
|
||||||
|
|
||||||
|
|
||||||
|
## Magic Project Opener
|
||||||
|
|
||||||
|
### proj / repo / wptheme [project]
|
||||||
|
|
||||||
|
Change current directory to project folder / Git repo / Wordpress theme forlder of given “project”. Use fuzzy search.
|
||||||
|
|
||||||
|
|
||||||
|
## Misc
|
||||||
|
|
||||||
|
### password [length]
|
||||||
|
|
||||||
|
Generate random password and copy it to clipboard. Default length is 8.
|
||||||
|
|
||||||
|
### path
|
||||||
|
|
||||||
|
Show $PATH in a readable way.
|
||||||
|
|
||||||
|
### dotfiles
|
||||||
|
|
||||||
|
Update dotfiles. Pull latest version from GitHub, syncronize symlinks and reread `~/.bashrc`.
|
||||||
|
|
||||||
|
### update
|
||||||
|
|
||||||
|
Get OS X software updates, update Homebrew, NPM, Ruby packages, dotfiles and some other software.
|
||||||
|
|
||||||
|
### nyan
|
||||||
|
|
||||||
|
Print nyan cat :-)
|
@ -28,15 +28,9 @@ function escape() {
|
|||||||
echo # newline
|
echo # newline
|
||||||
}
|
}
|
||||||
|
|
||||||
# Decode \x{ABCD}-style Unicode escape sequences
|
# Get a character’s Unicode code point: £ → \x00A3
|
||||||
function unidecode() {
|
|
||||||
perl -e "binmode(STDOUT, ':utf8'); print \"$@\""
|
|
||||||
echo # newline
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get a character’s Unicode code point
|
|
||||||
function codepoint() {
|
function codepoint() {
|
||||||
perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))"
|
perl -e "use utf8; print sprintf('\x%04X', ord(\"$@\"))"
|
||||||
echo # newline
|
echo # newline
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +80,7 @@ function nyan() {
|
|||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
# Creates an SSH key and uploads it to the given host
|
# Create an SSH key and uploads it to the given host
|
||||||
# Based on https://gist.github.com/1761938
|
# Based on https://gist.github.com/1761938
|
||||||
add-ssh-host() {
|
add-ssh-host() {
|
||||||
username=$1
|
username=$1
|
||||||
@ -169,21 +163,6 @@ function git-upstream() {
|
|||||||
git merge upstream/$branch
|
git merge upstream/$branch
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install/update all NPM tasks used in grunt.js in current folder
|
|
||||||
function npm-grunt() {
|
|
||||||
if [ ! -f "grunt.js" ]; then
|
|
||||||
echo "grunt.js not found."
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
npm update grunt -g
|
|
||||||
tasks=(`grep -oP "(?<=loadNpmTasks\(['\"])[^'\"]+" grunt.js`)
|
|
||||||
for task in "${tasks[@]}"
|
|
||||||
do
|
|
||||||
npm install $task -g
|
|
||||||
npm link $task
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Find files with Windows line endings (and convert then to Unix in force mode)
|
# Find files with Windows line endings (and convert then to Unix in force mode)
|
||||||
# USAGE: crlf [--force]
|
# USAGE: crlf [--force]
|
||||||
function crlf() {
|
function crlf() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Get OS X Software Updates, update Homebrew, NPM, Ruby packages, dotfiles and some other software
|
# Get OS X software updates, update Homebrew, NPM, Ruby packages, dotfiles and some other software
|
||||||
|
|
||||||
function header() {
|
function header() {
|
||||||
echo -e "$(tput sgr 0 1)$(tput setaf 6)$1$(tput sgr0)"
|
echo -e "$(tput sgr 0 1)$(tput setaf 6)$1$(tput sgr0)"
|
||||||
@ -16,7 +16,7 @@ cd "$HOME/dotfiles"
|
|||||||
git pull
|
git pull
|
||||||
./sync.py
|
./sync.py
|
||||||
source "$HOME/.bashrc"
|
source "$HOME/.bashrc"
|
||||||
cd - > /dev/null 2>&1
|
cd -
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# OS X
|
# OS X
|
||||||
|
Loading…
Reference in New Issue
Block a user