Merge branch 'master' of github.com:sapegin/dotfiles
This commit is contained in:
@ -17,6 +17,7 @@ alias oo="open ."
|
||||
alias e="subl"
|
||||
alias gh="github"
|
||||
alias +x="chmod +x"
|
||||
alias g="ack -ri"
|
||||
|
||||
# Detect which `ls` flavor is in use
|
||||
if ls --color > /dev/null 2>&1; then # GNU `ls`
|
||||
|
@ -111,14 +111,15 @@ ssh-key() {
|
||||
|
||||
# Create an SSH key and uploads it to the given host
|
||||
# Based on https://gist.github.com/1761938
|
||||
add-ssh-host() {
|
||||
ssh-add-host() {
|
||||
username=$1
|
||||
hostname=$2
|
||||
identifier=$3
|
||||
|
||||
if [[ "$identifier" == "" ]] || [[ "$username" == "" ]] || [[ "$hostname" == "" ]]; then
|
||||
echo "Usage: configure_ssh_host <username> <hostname> <identifier>"
|
||||
echo "Usage: ssh-add-host <username> <hostname> <identifier>"
|
||||
else
|
||||
header "Generating key..."
|
||||
if [ ! -f "$HOME/.ssh/$identifier.id_rsa" ]; then
|
||||
ssh-keygen -f ~/.ssh/$identifier.id_rsa -C "$USER $(date +'%Y/%m%/%d %H:%M:%S')"
|
||||
fi
|
||||
@ -127,6 +128,7 @@ add-ssh-host() {
|
||||
echo -e "Host $identifier\n\tHostName $hostname\n\tUser $username\n\tIdentityFile ~/.ssh/$identifier.id_rsa" >> ~/.ssh/config
|
||||
fi
|
||||
|
||||
header "Uploading key..."
|
||||
ssh $identifier 'mkdir -p .ssh && cat >> ~/.ssh/authorized_keys' < ~/.ssh/$identifier.id_rsa.pub
|
||||
|
||||
tput bold; ssh -o PasswordAuthentication=no $identifier true && { tput setaf 2; echo "SSH key added."; } || { tput setaf 1; echo "Failure"; }; tput sgr0
|
||||
@ -253,6 +255,27 @@ function rasterize() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Add note to Notes.app (OS X 10.8)
|
||||
# Usage: note "foo" or echo "foo" | note
|
||||
function note() {
|
||||
local text
|
||||
if [ -t 0 ]; then # Argument
|
||||
text="$1"
|
||||
else # Pipe
|
||||
text=$(cat)
|
||||
fi
|
||||
body=$(echo "$text" | sed -E 's|$|<br>|g')
|
||||
osascript >/dev/null <<EOF
|
||||
tell application "Notes"
|
||||
tell account "iCloud"
|
||||
tell folder "Notes"
|
||||
make new note with properties {name:"$text", body:"$body"}
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
||||
# 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; }"
|
||||
|
Reference in New Issue
Block a user