.profile, .functions: Add functions file
This commit is contained in:
parent
4ef37f3a69
commit
b42eacc539
38
.functions
Normal file
38
.functions
Normal file
@ -0,0 +1,38 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# .functions
|
||||
# Functions for interactive shells
|
||||
#
|
||||
|
||||
proj() {
|
||||
# Ensure we have an argument
|
||||
if [ -z ${1+x} ]; then
|
||||
echo "proj: requires argument"
|
||||
return 1
|
||||
fi
|
||||
projname="${1//[^ a-zA-Z0-9]/}"
|
||||
projdir="$HOME/Projects/$projname"
|
||||
# Ensure we have a ~/Projects directory
|
||||
mkdir -p "$HOME/Projects" > /dev/null 2>&1
|
||||
# cd into the project or make it if necessary
|
||||
if [ -d "$projdir" ]; then
|
||||
# It exists
|
||||
echo "Going to existing project \"$projname\""
|
||||
cd "$projdir"
|
||||
else
|
||||
# It does not exist
|
||||
echo "Creating new project \"$projname\""
|
||||
mkdir -p "$projdir"
|
||||
cd "$projdir"
|
||||
if which git > /dev/null 2>&1; then
|
||||
# Initialize git
|
||||
echo "Initializing git with .gitignore"
|
||||
git init > /dev/null 2>&1
|
||||
echo '*.swp' > .gitignore
|
||||
git add .gitignore > /dev/null 2>&1
|
||||
git commit -am "Create gitignore" > /dev/null 2>&1
|
||||
git status
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
3
.profile
3
.profile
@ -88,6 +88,9 @@ alias cp='cp -i'
|
||||
alias todo='$EDITOR "$HOME/Documents/todo"'
|
||||
alias waitwhat='echo $?'
|
||||
|
||||
# Source ~/.functions, if it exists
|
||||
[ -r "$HOME/.functions" ] && . "$HOME/.functions"
|
||||
|
||||
# Set up a default PS1
|
||||
# This *should* work for all terminals. I know it works on ksh
|
||||
_ps1() {
|
||||
|
Loading…
Reference in New Issue
Block a user