Skip to content

Commit

Permalink
Split up files and add install script
Browse files Browse the repository at this point in the history
  • Loading branch information
danielswaine committed May 3, 2020
1 parent 4e3b7f1 commit 995a125
Show file tree
Hide file tree
Showing 13 changed files with 585 additions and 135 deletions.
32 changes: 32 additions & 0 deletions .aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

# Navigation
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."

# Folder shortcuts
alias dx="cd ~/Dropbox"
alias dt="cd ~/Desktop"
alias pr="cd ~/Projects"

alias c="clear"
alias ls="ls -lsG"

# Show/hide hidden files in Finder
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"

# Hide/show all desktop icons
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"

# Ring the terminal bell, and put a badge on Terminal’s Dock icon
alias badge="tput bel"

# Lock the screen (when going AFK)
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"

# Kill all the tabs in Chrome to free up memory
alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
13 changes: 5 additions & 8 deletions .bash_profile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Load .profile and .bashrc
#!/usr/bin/env bash

if [ -f "$HOME/.profile" ]; then
. "$HOME/.profile"
fi

if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
for file in ~/.{bashrc,bash_prompt,aliases,functions,secrets,extras}; do
[ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
unset file;
44 changes: 44 additions & 0 deletions .bash_prompt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

# Parse current branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

# Custom Prompt
PROMPT_COMMAND='custom_prompt'
custom_prompt() {
exit_code=$?

bash_version=$(echo $BASH_VERSION | sed -e 's/\([0-9.]*\)(.*/\1/')
window_title="Bash $bash_version$(pwd | grep -o '[^/]\+$')"
msg=${debian_chroot:+($debian_chroot)}

if [[ $exit_code -ne 0 ]]; then
msg="\[\e[31m\] ✘ exit $exit_code\[\e[0m\]\n$msg"
fi

reset_colour="\[\e[0m\]"
date="\[\e[32m\][\d \$(date +%k:%M:%S)] "
user="${reset_colour}\u"
at="\[\e[97m\]@"
host="\[\e[36m\]\h "
git="\[\e[32m\]$(parse_git_branch)"
dir="\[\e[33m\]\w${git} \[\e[33m\]❯ "

PS1="${msg}${date}${user}${at}${host}${dir}${reset_colour}"

echo -n -e "\033]0;$window_title\007"
}

# For fun
# if which fortune boxes lolcat &> /dev/null; then
# echo
# fortune -s | boxes -d simple -p a1l3r3 | lolcat -F 0.5
# echo
# fi

# if which figlet lolcat boxes &> /dev/null; then
# figlet -f ogre -w 150 "hello" $USER | boxes -d simple -p a1l3r3
# echo
# fi
104 changes: 3 additions & 101 deletions .bashrc
Original file line number Diff line number Diff line change
@@ -1,104 +1,6 @@
#!/usr/bin/env bash

# Test for non-interactive shells
[[ $- == *i* ]] || return 0

# Load bits
eval "$(rbenv init -)"

export PATH=/usr/local/bin:$PATH


# Open man page as PDF
function manpdf() {
man -t "${1}" | open -f -a /Applications/Preview.app/
}

# Create a new directory and enter it
function mk() {
mkdir -p "$1" && cd "$1"
}

# Change into the top-most Finder window's location
function cdf() { # short for `cdfinder`
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
}

# With no arguments opens the current directory in Atom, otherwise
# opens the given location
function a() {
if [ $# -eq 0 ]; then
atom .
else
atom "$@"
fi
}


# Navigation
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."

# Folder shortcuts
alias dx="cd ~/Dropbox"
alias dt="cd ~/Desktop"
alias pr="cd ~/Projects"

alias c="clear"
alias ls="ls -lsG"

# Show/hide hidden files in Finder
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"

# Hide/show all desktop icons
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"

# Ring the terminal bell, and put a badge on Terminal’s Dock icon
alias badge="tput bel"

# Parse current branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}


# Custom Prompt
PROMPT_COMMAND='custom_prompt'
custom_prompt() {
exit_code=$?

bash_version=$(echo $BASH_VERSION | sed -e 's/\([0-9.]*\)(.*/\1/')
window_title="Bash $bash_version$(pwd | grep -o '[^/]\+$')"
msg=${debian_chroot:+($debian_chroot)}

if [[ $exit_code -ne 0 ]]; then
msg="\[\e[31m\] ✘ exit $exit_code\[\e[0m\]\n$msg"
fi

reset_colour="\[\e[0m\]"
date="\[\e[32m\][\d \$(date +%k:%M:%S)] "
user="${reset_colour}\u"
at="\[\e[97m\]@"
host="\[\e[36m\]\h "
git="\[\e[32m\]$(parse_git_branch)"
dir="\[\e[33m\]\w${git} \[\e[33m\]❯ "

PS1="${msg}${date}${user}${at}${host}${dir}${reset_colour}"

echo -n -e "\033]0;$window_title\007"
}


# For fun
if which fortune boxes lolcat &> /dev/null; then
echo
fortune -s | boxes -d simple -p a1l3r3 | lolcat -F 0.5
echo
fi

# if which figlet lolcat boxes &> /dev/null; then
# figlet -f ogre -w 150 "hello" $USER | boxes -d simple -p a1l3r3
# echo
# fi
if which rbenv &> /dev/null; then eval "$(rbenv init -)"; fi
8 changes: 8 additions & 0 deletions .exports
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

export HISTCONTROL=ignoreboth # Forget duplicate and space-prefixed commands.
export HISTFILESIZE=1000 # Maximum number of commands saved in .bash_history.
export HISTSIZE=500 # Maximum number of commands to remember from one session.

# Enable colour for 'grep' output
export GREP_OPTIONS="--color=auto"
26 changes: 26 additions & 0 deletions .functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# Open man page as PDF
function manpdf() {
man -t "${1}" | open -f -a /Applications/Preview.app/
}

# Create a new directory and enter it
function mk() {
mkdir -p "$1" && cd "$1"
}

# Change into the top-most Finder window's location
function cdf() { # short for `cdfinder`
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
}

# With no arguments opens the current directory in Atom, otherwise
# opens the given location
function a() {
if [ $# -eq 0 ]; then
atom .
else
atom "$@"
fi
}
4 changes: 0 additions & 4 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[user]
name = Daniel Swaine
email = [email protected]

[core]
excludesfile = ~/.globalgitignore
editor = atom
Expand Down
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
!.gitconfig
!.gitignore
!.globalgitignore
!.profile
!.irbrc
!.tmux.conf
!.aliases
!.bash_prompt
!.exports
!.functions
!.hushlogin
!.macos
!install.sh

!.config
!.config/nvim
Expand All @@ -23,3 +29,6 @@
!.config/nvim/init.vim
!.config/nvim/UltiSnips/
!.config/nvim/UltiSnips/*.snippets

!resources
!resources/SolarizedDark.itermcolors
Empty file added .hushlogin
Empty file.
Loading

0 comments on commit 995a125

Please sign in to comment.