From dede2966180fcfc702500d4d0b7d6a368aa97336 Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Thu, 10 Jan 2013 14:56:34 +0400 Subject: [PATCH] Bash: some+ aliases generator + few tweaks. --- bin/archive-project | 3 +++ includes/bash_aliases.bash | 6 +++--- includes/bash_functions.bash | 9 +++++++-- tilde/bash_profile.bash | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bin/archive-project b/bin/archive-project index 5dd494b..40225b6 100755 --- a/bin/archive-project +++ b/bin/archive-project @@ -50,6 +50,9 @@ echo # Clean echo "Cleaning..." +# Optimize repo +git gc + # Remove node_modules find . -name node_modules -print0 | xargs -0 rm -rf diff --git a/includes/bash_aliases.bash b/includes/bash_aliases.bash index ce9b685..e9e2e2e 100644 --- a/includes/bash_aliases.bash +++ b/includes/bash_aliases.bash @@ -77,7 +77,7 @@ done alias dos2unix="perl -pi -e 's/\r\n?/\n/g'" # Password generator -password() { openssl rand -base64 ${1:-8} | c; } +password() { openssl rand -base64 ${1:-8}; } # Show $PATH in a readable way alias path='echo -e ${PATH//:/\\n}' @@ -88,8 +88,8 @@ alias npm-release='npm version minor -m "%s"' # Grunt alias gw="grunt deploy --debug && grunt watch --debug" -alias gs="grunt deploy --debug && grunt serve --debug" -gi() { grunt init:$@; } +alias gs="grunt deploy --debug && grunt watch server --debug" +gi() { grunt-init $@; } # Magic Project Opener function proj { cd "$("$HOME/dotfiles/bin/opener.py" "$HOME/Dropbox/Projects" $1 -w project $2)"; } diff --git a/includes/bash_functions.bash b/includes/bash_functions.bash index 43ab803..bfd3f76 100644 --- a/includes/bash_functions.bash +++ b/includes/bash_functions.bash @@ -40,13 +40,13 @@ function headers() { # Escape UTF-8 characters into their 3-byte format function escape() { printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u) - echo # newline + echo } # Get a character’s Unicode code point: £ → \x00A3 function codepoint() { perl -e "use utf8; print sprintf('\x%04X', ord(\"$@\"))" - echo # newline + echo } # Remove screenshots from desktop @@ -238,3 +238,8 @@ function rasterize() { echo "Screenshot saved to: $filename" fi } + +# Add special aliases that will copy result to clipboard (escape → escape+) +for cmd in password hex2hsl hex2rgb escape codepoint; do + eval "function $cmd+() { $cmd \$@ | c; }" +done diff --git a/tilde/bash_profile.bash b/tilde/bash_profile.bash index 7bb0cad..578451f 100644 --- a/tilde/bash_profile.bash +++ b/tilde/bash_profile.bash @@ -42,8 +42,8 @@ function _prepend_path() { [ -d /usr/local/bin ] && _prepend_path "/usr/local/bin" [ -d /usr/local/share/npm/bin ] && _prepend_path "/usr/local/share/npm/bin" command -v brew >/dev/null 2>&1 && _prepend_path "$(brew --prefix coreutils)/libexec/gnubin" -[ -d ~/dotfiles/bin ] && _prepend_path "~/dotfiles/bin" -[ -d ~/bin ] && _prepend_path "~/bin" +[ -d ~/dotfiles/bin ] && _prepend_path "$HOME/dotfiles/bin" +[ -d ~/bin ] && _prepend_path "$HOME/bin" export PATH # Colors