Skip to content

Instantly share code, notes, and snippets.

@coderek
Last active December 30, 2017 19:36
Show Gist options
  • Save coderek/eb7dc716c39dcc611959 to your computer and use it in GitHub Desktop.
Save coderek/eb7dc716c39dcc611959 to your computer and use it in GitHub Desktop.
bashrc
#! /bin/sh
alias today='date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S %Z"'
if hash ggrep 2>/dev/null; then
alias grep='ggrep --color=auto -n -P'
fi
alias get='git grep --color=auto -n -P'
unset work
# work on an project in /Code/projects folder
work() {
if [ $# -ne 1 ]
then
echo "Please specify a project"
else
if [ -d "/Code/$1" ]
then
echo "work on project $1"
local prefix="$1_tmux"
local session_name="${prefix}_session"
local vim_window_name="${prefix}_vim"
local control_window_name="${prefix}_control"
tmux has-session -t $session_name > /dev/null 2>&1
if [ $? -eq 0 ]
then
tmux attach -t $session_name
else
tmux new-session -d -s $session_name -n $vim_window_name -c "/Code/$1" vim
tmux new-window -t "$session_name" -n $control_window_name -c "/Code/$1"
if [ $1 = 'snake' ]
then
tmux split-window -d -t "$control_window_name" -c "/Code/$1" 'python -m http.server 8001'
tmux split-window -d -t "$control_window_name" -c "/Code/$1" 'yarn run watch'
elif [ $1 = 'mysite' ]
then
tmux split-window -d -t "$control_window_name" -c "/Code/$1" 'sudo docker-compose up'
fi
tmux select-layout -t "$session_name:$control_window_name" main-vertical
tmux attach -t $session_name
fi
else
echo "Project entered does not exist"
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment