fixed up the ssh_agent fixer. updated some of the debian stuff.

This commit is contained in:
Ivan Malison 2013-03-31 22:22:56 +00:00
parent caf785b53b
commit da4104da8d
6 changed files with 85 additions and 102 deletions

17
.debian
View File

@ -1,16 +1,5 @@
sudo -v
INSTALL="apt-get -y install"
INSTALL="sudo apt-get -y install"
$INSTALL zsh
$INSTALL tmux
$INSTALL emacs
$INSTALL nmap
$INSTALL readline
# python dependencies
$INSTALL libreadline5-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
cd ~/Downloads
wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar -xvf Python-2.7.2.tgz && cd Python-2.7.2/
./configure
make
sudo make altinstall
$INSTALL emacs24-nox
$INSTALL nmap

View File

@ -21,10 +21,4 @@ export LESS_TERMCAP_md="$ORANGE"
export MANPAGER="less -X"
git config --global user.name "Ivan Malison"
git config --global user.email IvanMalison@gmail.com
# EC2 stuff.
export JAVA_HOME="$(/usr/libexec/java_home)"
export EC2_PRIVATE_KEY="$(/bin/ls "$HOME"/.ec2/pk-*.pem | /usr/bin/head -1)"
export EC2_CERT="$(/bin/ls "$HOME"/.ec2/cert-*.pem | /usr/bin/head -1)"
export EC2_HOME="/usr/local/Library/LinkedKegs/ec2-api-tools/jars"
git config --global user.email IvanMalison@gmail.com

View File

@ -1,136 +1,142 @@
source ~/ssh-find-agent/ssh-find-agent.bash
find_all_ssh_agent_sockets() {
find /tmp -type s -name agent.\* 2> /dev/null | grep '/tmp/ssh-.*/agent.*'
}
set_ssh_agent_socket() {
export SSH_AUTH_SOCK=$(find_all_ssh_agent_sockets | tail -n 1 | awk -F: '{print $1}')
}
# Simple calculator
function calc() {
local result=""
result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')"
local result=""
result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')"
# └─ default (when `--mathlib` is used) is 20
#
if [[ "$result" == *.* ]]; then
if [[ "$result" == *.* ]]; then
# improve the output for decimal numbers
printf "$result" |
sed -e 's/^\./0./' `# add "0" for cases like ".5"` \
-e 's/^-\./-0./' `# add "0" for cases like "-.5"`\
printf "$result" |
sed -e 's/^\./0./' `# add "0" for cases like ".5"` \
-e 's/^-\./-0./' `# add "0" for cases like "-.5"`\
-e 's/0*$//;s/\.$//' # remove trailing zeros
else
printf "$result"
fi
printf "\n"
else
printf "$result"
fi
printf "\n"
}
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$@"
mkdir -p "$@" && cd "$@"
}
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh
else
local arg=-sh
fi
if [[ -n "$@" ]]; then
du $arg -- "$@"
else
du $arg .[^.]* *
fi
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh
else
local arg=-sh
fi
if [[ -n "$@" ]]; then
du $arg -- "$@"
else
du $arg .[^.]* *
fi
}
# Use Gits colored diff when available
hash git &>/dev/null
if [ $? -eq 0 ]; then
function diff() {
git diff --no-index --color-words "$@"
}
function diff() {
git diff --no-index --color-words "$@"
}
fi
# Create a data URL from a file
function dataurl() {
local mimeType=$(file -b --mime-type "$1")
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8"
fi
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')"
local mimeType=$(file -b --mime-type "$1")
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8"
fi
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')"
}
# Start an HTTP server from a directory, optionally specifying the port
function server() {
local port="${1:-8000}"
sleep 1 && open "http://localhost:${port}/" &
local port="${1:-8000}"
sleep 1 && open "http://localhost:${port}/" &
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesnt break anything for binary files)
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}
# Start a PHP server from a directory, optionally specifying the port
# (Requires PHP 5.4.0+.)
function phpserver() {
local port="${1:-4000}"
local ip=$(ipconfig getifaddr en1)
sleep 1 && open "http://${ip}:${port}/" &
php -S "${ip}:${port}"
local port="${1:-4000}"
local ip=$(ipconfig getifaddr en1)
sleep 1 && open "http://${ip}:${port}/" &
php -S "${ip}:${port}"
}
# Compare original and gzipped file size
function gz() {
local origsize=$(wc -c < "$1")
local gzipsize=$(gzip -c "$1" | wc -c)
local ratio=$(echo "$gzipsize * 100/ $origsize" | bc -l)
printf "orig: %d bytes\n" "$origsize"
printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio"
local origsize=$(wc -c < "$1")
local gzipsize=$(gzip -c "$1" | wc -c)
local ratio=$(echo "$gzipsize * 100/ $origsize" | bc -l)
printf "orig: %d bytes\n" "$origsize"
printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio"
}
# 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. (Looking at you, ajax.googleapis.com!)
function httpcompression() {
encoding="$(curl -LIs -H 'User-Agent: Mozilla/5 Gecko' -H 'Accept-Encoding: gzip,deflate,compress,sdch' "$1" | grep '^Content-Encoding:')" && echo "$1 is encoded using ${encoding#* }" || echo "$1 is not using any encoding"
encoding="$(curl -LIs -H 'User-Agent: Mozilla/5 Gecko' -H 'Accept-Encoding: gzip,deflate,compress,sdch' "$1" | grep '^Content-Encoding:')" && echo "$1 is encoded using ${encoding#* }" || echo "$1 is not using any encoding"
}
# Syntax-highlight JSON strings or files
# Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json`
function json() {
if [ -t 0 ]; then # argument
python -mjson.tool <<< "$*" | pygmentize -l javascript
else # pipe
python -mjson.tool | pygmentize -l javascript
fi
if [ -t 0 ]; then # argument
python -mjson.tool <<< "$*" | pygmentize -l javascript
else # pipe
python -mjson.tool | pygmentize -l javascript
fi
}
# All the dig info
function digga() {
dig +nocmd "$1" any +multiline +noall +answer
dig +nocmd "$1" any +multiline +noall +answer
}
# Escape UTF-8 characters into their 3-byte format
function escape() {
printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u)
echo # newline
printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u)
echo # newline
}
# Decode \x{ABCD}-style Unicode escape sequences
function unidecode() {
perl -e "binmode(STDOUT, ':utf8'); print \"$@\""
echo # newline
perl -e "binmode(STDOUT, ':utf8'); print \"$@\""
echo # newline
}
# Get a characters Unicode code point
function codepoint() {
perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))"
echo # newline
perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))"
echo # newline
}
# 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
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"
@ -144,13 +150,13 @@ EOF
# Add reminder to Reminders.app (OS X 10.8)
# Usage: `remind 'foo'` or `echo 'foo' | remind`
function remind() {
local text
if [ -t 0 ]; then
text="$1" # argument
else
text=$(cat) # pipe
fi
osascript >/dev/null <<EOF
local text
if [ -t 0 ]; then
text="$1" # argument
else
text=$(cat) # pipe
fi
osascript >/dev/null <<EOF
tell application "Reminders"
tell the default list
make new reminder with properties {name:"$text"}
@ -161,7 +167,7 @@ EOF
# Manually remove a downloaded app or file from the quarantine
function unquarantine() {
for attribute in com.apple.metadata:kMDItemDownloadedDate com.apple.metadata:kMDItemWhereFroms com.apple.quarantine; do
xattr -r -d "$attribute" "$@"
done
}
for attribute in com.apple.metadata:kMDItemDownloadedDate com.apple.metadata:kMDItemWhereFroms com.apple.quarantine; do
xattr -r -d "$attribute" "$@"
done
}

5
.gitmodules vendored
View File

@ -6,7 +6,4 @@
url = git@github.com:IvanMalison/.emacs.d.git
[submodule "oh-my-zsh"]
path = oh-my-zsh
url = git@github.com:IvanMalison/oh-my-zsh.git
[submodule "ssh-find-agent"]
path = ssh-find-agent
url = git@github.com:wwalker/ssh-find-agent.git
url = git@github.com:IvanMalison/oh-my-zsh.git

View File

@ -52,8 +52,6 @@ function install_python_packages() {
}
sudo -v
[ "$1" == "--install" -o "$1" == "-i" ] && echo "Installing essential files." && install_essentials
echo "Installing Dot Files."
source bootstrap.sh
echo "Installing Tmux Configuration."

@ -1 +0,0 @@
Subproject commit ecb780effadc3e95e5e5b9997448294f784def96