Last active
October 8, 2015 18:09
-
-
Save neuroticnerd/52f41ef0aea6ee156154 to your computer and use it in GitHub Desktop.
Useful Bash profile aliases and functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/env bash | |
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi | |
############################################################################### | |
### use local directories for homebrew and python | |
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH" | |
############################################################################### | |
### virtualenv setup and shortcuts | |
export PIP_REQUIRE_VIRTUALENV=true | |
export WORKON_HOME="~/envs" | |
source /usr/local/bin/virtualenvwrapper.sh | |
#export VIRTUALENVWRAPPER_PYTHON="/usr/local/bin/python2.7" | |
alias mkvenv="mkvirtualenv" | |
alias lsvenv="lsvirtualenv" | |
alias rmvenv="rmvirtualenv" | |
############################################################################### | |
### editing shortcuts | |
alias sublime="sudo subl" | |
export TEXT_EDITOR="sublime" | |
export EDITOR="subl" | |
alias profileedit="$TEXT_EDITOR ~/.bash_profile" | |
alias profileload="source ~/.bash_profile" | |
alias reprofile="profileedit && profileload" | |
alias sshconf="$TEXT_EDITOR ~/.ssh/config" | |
alias sshhosts="$TEXT_EDITOR ~/.ssh/known_hosts" | |
alias sshauthed="$TEXT_EDITOR ~/.ssh/authorized_keys" | |
alias hosts="sudo sublime /private/etc/hosts" | |
############################################################################### | |
### general shortcuts | |
alias resetdns="dscacheutil -flushcache && sudo killall -HUP mDNSResponder" | |
alias ipecho="wget -qO- http://ipecho.net/plain ; echo" | |
alias showall="defaults write com.apple.finder AppleShowAllFiles YES; kfinder" | |
alias showhide="defaults write com.apple.finder AppleShowAllFiles NO; kfinder" | |
alias kfinder="sudo killall Finder /System/Library/CoreServices/Finder.app" | |
alias repos="cd ~/git" | |
alias cask="brew cask" | |
############################################################################### | |
### UTILITY -- requires `brew install coreutils` for linux-style ls on mac | |
export LS_COMMAND="gls" | |
alias ls="$LS_COMMAND" | |
alias lsa="ls -Ahl --color --group-directories-first" | |
alias lsaa="ls -ahl --color --group-directories-first" | |
alias nfind="sudo find / -name" | |
alias psfind="ps aux | grep" | |
alias pubpem="openssl rsa -pubout -outform pem -in" # $> pubpem keyfile.pem | |
function pubssh() | |
{ | |
# http://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash | |
local HELPTEXT="usage of pubssh:" | |
HELPTEXT="$HELPTEXT\n pubssh keyfile [outputfile [comment]]" | |
pushd ~/.ssh > /dev/null | |
if [ ! -z "$1" ]; then | |
if [ "--help" = "$1" ]; then | |
echo -e "$HELPTEXT"; | |
else | |
local PUBKEY=$(ssh-keygen -y -f $1); | |
if [ ! -z "$2" ]; then | |
printf "%s" "$PUBKEY" > $2; | |
if [ ! -z "$3" ]; then | |
printf " %s\n" "$3" >> $2; | |
PUBKEY="$PUBKEY $3" | |
fi | |
echo "### showing contents of ~/.ssh/$2 ###" | |
sudo cat $2 | |
echo "" | |
else | |
echo $PUBKEY | |
echo -e "\nnothing written to file." | |
fi | |
fi | |
else | |
echo -e "$HELPTEXT"; | |
fi | |
popd > /dev/null | |
} | |
function lsgrep() { ls $2 | grep $1; } | |
function cdls() { cd "$@" && ls; } | |
function gpip() | |
{ | |
PIP_REQUIRE_VIRTUALENV="" pip "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment