Skip to content

Instantly share code, notes, and snippets.

View adamheins's full-sized avatar

Adam Heins adamheins

View GitHub Profile
@adamheins
adamheins / git-branch.sh
Created September 21, 2015 06:16
Get the current branch for your git repo in bash.
#/bin/bash
# If the cwd is a git repo, display the branch name in the tmux status bar.
get_git_branch() {
if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
local branch short_branch
branch=$(git symbolic-ref -q HEAD)
branch=${branch##refs/heads/}
branch=${branch:-HEAD}
short_branch=$(echo "$branch" | cut -c1-20)
@adamheins
adamheins / jira.sh
Last active November 23, 2015 05:05
Simple tool for opening issues and starting a JIRA search from the command line (OSX).
#!/bin/bash
# Simple JIRA CLI utility.
# Currently only works on OSX (since it makes use of OSX's built-in
# open command).
jira() {
if [ -z "$1" ]; then
open "$JIRA_URL""/secure/Dashboard.jspa"
return 0
@adamheins
adamheins / colors.sh
Created September 21, 2015 06:05
Bash function for displaying all 256 colors with codes in the terminal.
#!/bin/bash
# Print all of the terminal colors.
colors() {
local count=0
local cols=$(tput cols)
for i in {0..255}; do
((count+=4))
if [ $count -gt $cols ]; then
printf "\n"
@adamheins
adamheins / dir_aliases.sh
Created September 21, 2015 06:02
Bash aliases for directory navigation.
#!/bin/bash
# Aliases for changing directories.
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias -- -="cd - >/dev/null 2>&1"