Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhadley committed May 13, 2016
1 parent 6de53d0 commit a4dc3d4
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 69 deletions.
5 changes: 5 additions & 0 deletions bashrc.d/00.env.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Get TTY number, last 2 digits
TTY_NUM=$(tty|cut -c11-)

# Prevent tar include "._" file resource forks
export COPYFILE_DISABLE=true
15 changes: 1 addition & 14 deletions source/00.env → bashrc.d/00.history.bash
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# Get TTY number
TTY_NUM=$(tty|cut -c10-)

# Use vim
export EDITOR=vim

# Prevent tar include "._" file resource forks
export COPYFILE_DISABLE=true

# Don't add duplicate commands or commands that start with a space to bash history
HISTCONTROL=ignoreboth
# Append history instead of rewriting it
Expand All @@ -19,8 +10,4 @@ HISTTIMEFORMAT='%F %T '

# bash_history per ttyl
mkdir -p $HOME/.history.d
HISTFILE="$HOME/.history.d/"$(uname -n)"-"$TTY_NUM

# Git state in PS1
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
HISTFILE="$HOME/.history.d/$HOSTNAME-$TTY_NUM"
File renamed without changes.
4 changes: 4 additions & 0 deletions source/01.prompt → bashrc.d/00.prompt.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# http://stackoverflow.com/questions/3058325/what-is-the-difference-between-ps1-and-prompt-command
# http://stackoverflow.com/questions/1371261/get-current-directory-name-without-full-path-in-bash-script

# Git state in PS1
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1

# show 2 levels of directory listing for iterm2 tab
# check not running on local console
if [ "$(tty | grep pts | wc -l)" -ge "1" ];then
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions bashrc.d/01.editor.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Use vim
export EDITOR=vim
48 changes: 48 additions & 0 deletions bashrc.d/01.functions.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# display file/directory permissions in octal format
perms() {
# default to all visible files/directories
local input=*
if [ ! -z "$1" ]; then
input=$@
fi
# check to also show hidden files/directories
if [ "$1" == "-a" ]; then
input=".* *"
fi
if [ "$(uname)" == "Darwin" ]; then
stat -f '%A %N' $input 2>/dev/null
else
stat -c '%A %a %n' $input 2>/dev/null
fi
}

# Repeat a command mulitple times
repeat() {
local n=$1
shift
while [ $(( n -= 1 )) -ge 0 ]
do
"$@"
done
}

# remove known_hosts entry
unknow_host() {
if [ -z "$1" ];then
echo "error: missing hostname"
return
fi
echo "removing host $1"
ssh-keygen -R $1 &>/dev/null
}

# cd to parent directory of symlinked file
cds() {
local realpath=$(readlink $1)
cd $(dirname "$realpath")
}

# make a directory and cd into it
md() {
mkdir -p "$@" && cd "$@";
}
File renamed without changes.
45 changes: 0 additions & 45 deletions source/01.functions → bashrc.d/01.git-functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -122,48 +122,3 @@ ghi() {
fi
GHI_TOKEN=$(keychain -g "$TOKEN_TYPE") TERM=xterm-256color /usr/local/bin/ghi --no-pager "$@"
}

# display file permissions in octal format
perms() {
local input=*
if [ ! -z "$1" ]; then
input=$@
fi
if [ "$OS" == "Darwin" ]; then
stat -f '%A %N' $input
else
stat -c '%A %a %n' $input
fi
}

# Repeat a command mulitple times
repeat() {
local n=$1
shift
while [ $(( n -= 1 )) -ge 0 ]
do
"$@"
done
}

# remove known_hosts entry
unknow_host() {
if [ -z "$1" ];then
echo "error: missing hostname"
return
fi
echo "removing host $1"
ssh-keygen -R $1 &>/dev/null
rm $HOME/.ssh/known_hosts.old 2>/dev/null
}

# cd to parent directory of symlinked file
cds() {
local realpath=$(readlink $1)
cd $(dirname "$realpath")
}

# make a directory and cd into it
md() {
mkdir -p "$@" && cd "$@";
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ alias sbn='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n .'
# docker
alias docker-init='. /Applications/Docker/Docker\ Quickstart\ Terminal.app/Contents/Resources/Scripts/start.sh'

# npm
alias npm-public='npm --registry https://registry.npmjs.org'
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# channel git calls
hash git 2>&- && { export GIT_PATH=$(which git); }

git(){
if [ "$1" == "commit" -o "$1" == "clone" ];then
$GIT_CORP "$@"
Expand Down
File renamed without changes.
10 changes: 4 additions & 6 deletions dotfiles/bashrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## bash.rc
export DOTFILES=$HOME/.dotfiles

export OS=`uname`
if [ "$OS" == "Darwin" ]; then
export PLATFORM='osx'
Expand All @@ -18,7 +18,6 @@ else
export PLATFORM='unknown'
fi


function source_rc() {
for rc in $1/*; do
if [ -f $rc ]; then
Expand All @@ -27,7 +26,6 @@ function source_rc() {
done
}

source_rc $DOTFILES/source
source_rc $DOTFILES/source/platform/$PLATFORM
source_rc $DOTFILES/source/os/$OS
source_rc $DOTFILES/source/host/$HOSTNAME
source_rc $HOME/.dotfiles/bashrc.d
source_rc $HOME/.dotfiles/bashrc.d/platform/$PLATFORM
source_rc $HOME/.dotfiles/bashrc.d/hostname/$HOSTNAME
2 changes: 0 additions & 2 deletions source/profile/README.md

This file was deleted.

0 comments on commit a4dc3d4

Please sign in to comment.