Merge branch 'master' of git://github.com/revans/bash-it

pull/62/head
Anton Shemerey 2011-06-28 12:22:47 +03:00
commit 692d358f43
17 changed files with 406 additions and 231 deletions

3
.gitignore vendored
View File

@ -1,5 +1,4 @@
aliases/enabled
plugins/enabled
*/enabled/*
.DS_Store
custom/*.bash
!custom/example.bash

View File

@ -6,12 +6,19 @@ Includes some autocompletion tools, theming support, aliases, custom functions,
## Install
Check a clone of this repo. You can view what a sample `~/.bash_profile` looks like in `template/bash_profile.template.bash`. If you wanted to use that template, make sure to make a backup of your current `~/.bash_profile` file.
Check a clone of this repo:
git clone http://github.com/revans/bash-it.git bash_it
cp ~/.bash_profile ~/.bash_profile_original
cp <path/to/cloned/repo>/template/bash_profile.template.bash ~/.bash_profile
Then run the `install.sh` file, it will backup your `~/.bash_profile`
file and move the template one into it's place (the template file is at
`~/.bash_it/template/bash_profile.template.bash`). Be sure to edit this
template file in order to customize bash-it.
The install script will also prompt
you asking if you use [Jekyll](https://github.com/mojombo/jekyll). This
is to set up the `.jekyllconfig` file, the file that stores the
information needed to use the Jekyll plugin supplied with bash it.
## Help Screens
@ -34,13 +41,13 @@ and anything in the custom directory will be ignored with the exception of `cust
## Themes
There are a few bash-it themes, but I'm hoping the community will jump in and create their own custom prompts and share their creations with everyone else by submitting a pull request to me (revans).
There are a few bash it themes, but I'm hoping the community will jump in and create their own custom prompts and share their creations with everyone else by submitting a pull request to me (revans).
## Help out
I think all of us have our own custom scripts that we have added over time and so following in the footsteps of oh-my-zsh, bash-it was created as a framework for those who choose to use bash as their shell. As a community, I'm excited to see what everyone else has in their custom toolbox and am hoping that they'll share it with everyone by submitting a pull request to bash-it.
I think all of us have our own custom scripts that we have added over time and so following in the footsteps of oh-my-zsh, bash it was created as a framework for those who choose to use bash as their shell. As a community, I'm excited to see what everyone else has in their custom toolbox and am hoping that they'll share it with everyone by submitting a pull request to bash it.
So, if you have contributions to bash-it, please send me a pull request and I'll take a look at it and commit it to the repo as long as it looks good. If you do change an existing command, please give an explanation as to why. That will help a lot when I merge your changes in. Thanks, and happing bashing!
So, if you have contributions to bash it, please send me a pull request and I'll take a look at it and commit it to the repo as long as it looks good. If you do change an existing command, please give an explanation as to why. That will help a lot when I merge your changes in. Thanks, and happing bashing!
## Contributors

View File

@ -1,20 +0,0 @@
# Open the root of your site in your vim or builtin cd to it
if [[ $EDITOR = "vim" ]]
then
alias newentry="builtin cd $JEKYLL_LOCAL_ROOT && $EDITOR ."
else
alias newentry="builtin cd $JEKYLL_LOCAL_ROOT"
fi
# Build and locally serve the site
alias testsite="builtin cd $JEKYLL_LOCAL_ROOT && jekyll --server --auto"
# Build but don't locally serve the site
alias buildsite="builtin cd $JEKYLL_LOCAL_ROOT && rm -rf _site/ && jekyll"
# Rsync the site to the remote server
alias deploysite="builtin cd $JEKYLL_LOCAL_ROOT && rsync -rz _site/ $JEKYLL_REMOTE_ROOT"

View File

@ -17,37 +17,22 @@ do
source $config_file
done
# Tab Completion
COMPLETION="${BASH}/completion/*.bash"
for config_file in $COMPLETION
# Load enabled aliases, completion, plugins
for file_type in "aliases" "completion" "plugins"
do
source $config_file
done
# Plugins
if [ ! -d "${BASH}/plugins/enabled" ]
if [ ! -d "${BASH}/${file_type}/enabled" ]
then
mkdir "${BASH}/plugins/enabled"
ln -s ${BASH}/plugins/available/* "${BASH}/plugins/enabled"
mkdir "${BASH}/${file_type}/enabled"
ln -s ${BASH}/${file_type}/available/* "${BASH}/${file_type}/enabled"
fi
PLUGINS="${BASH}/plugins/enabled/*.bash"
for config_file in $PLUGINS
FILES="${BASH}/${file_type}/enabled/*.bash"
for config_file in $FILES
do
source $config_file
done
# Aliases
if [ ! -d "${BASH}/aliases/enabled" ]
then
mkdir "${BASH}/aliases/enabled"
ln -s ${BASH}/aliases/available/* "${BASH}/aliases/enabled"
fi
FUNCTIONS="${BASH}/aliases/enabled/*.bash"
for config_file in $FUNCTIONS
do
source $config_file
done
# Load any custom aliases that the user has added
if [ -e "${BASH}/aliases/custom.aliases.bash" ]
then
source "${BASH}/aliases/custom.aliases.bash"
@ -71,6 +56,13 @@ PREVIEW="less"
[ -s /usr/bin/gloobus-preview ] && PREVIEW="gloobus-preview"
[ -s /Applications/Preview.app ] && PREVIEW="/Applications/Preview.app"
# Load all the Jekyll stuff
if [ -e $HOME/.jekyllconfig ]
then
. $HOME/.jekyllconfig
fi
#
# Custom Help

28
install.sh 100755
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
cp $HOME/.bash_profile $HOME/.bash_profile.bak
echo "Your original .bash_profile has been backed up to .bash_profile.bak"
cp $HOME/.bash_it/template/bash_profile.template.bash $HOME/.bash_profile
echo "Copied the template .bash_profile into ~/.bash_profile, edit this file to customize bash-it"
while true
do
read -p "Do you use Jekyll? (If you don't know what Jekyll is, answer 'n') [Y/N] " RESP
case $RESP
in
[yY])
cp $HOME/.bash_it/template/jekyllconfig.template.bash $HOME/.jekyllconfig
echo "Copied the template .jekyllconfig into your home directory. Edit this file to customize bash-it for using the Jekyll plugins"
break
;;
[nN])
break
;;
*)
echo "Please enter Y or N"
esac
done

View File

@ -1,7 +1,30 @@
#!/bin/bash
editpost() {
builtin cd "$JEKYLL_LOCAL_ROOT/_posts"
unset SITE
if [ -z "$1" ]
then
echo "Error: no site specified."
echo "The site is the name of the directory your project is in."
return 1
fi
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
then
SITE=$site
break
fi
done
if [ -z "$SITE" ]
then
echo "No such site."
return 1
fi
builtin cd "$SITE/_posts"
COUNTER=1
NUMBER="$RANDOM"
@ -27,16 +50,42 @@ editpost() {
}
newpost() {
unset SITE
if [ -z "$1" ]
then
echo "Error: no site specified."
echo "The site is the name of the directory your project is in."
return 1
fi
if [ -z "$SITE" ]
then
echo "No such site."
return 1
fi
loc=0
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
then
SITE=$site
JEKYLL_FORMATTING=${MARKUPS[$loc]}
break
fi
loc=$(($loc+1))
done
# 'builtin cd' into the local jekyll root
builtin cd "$JEKYLL_LOCAL_ROOT/_posts"
builtin cd "$SITE/_posts"
# Get the date for the new post's filename
FNAME_DATE=$(date "+%Y-%m-%d")
# If the user is using markdown formatting, let them choose what type of post they want. Sort of like Tumblr.
# If the user is using markdown or textile formatting, let them choose what type of post they want. Sort of like Tumblr.
OPTIONS="Text Quote Image Audio Video Link"
@ -206,3 +255,92 @@ newpost() {
"$EDITOR" $FNAME
}
function testsite() {
unset SITE
if [ -z "$1" ]
then
echo "Error: no site specified."
echo "The site is the name of the directory your project is in."
return 1
fi
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
then
SITE=$site
break
fi
done
if [ -z "$SITE" ]
then
echo "No such site."
return 1
fi
builtin cd $SITE
jekyll --server --auto
}
function buildsite() {
unset SITE
if [ -z "$1" ]
then
echo "Error: no site specified."
echo "The site is the name of the directory your project is in."
return 1
fi
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
then
SITE=$site
break
fi
done
if [ -z "$SITE" ]
then
echo "No such site."
return 1
fi
builtin cd $SITE
rm -rf _site
jekyll --no-server
}
function deploysite() {
unset SITE
if [ -z "$1" ]
then
echo "Error: no site specified."
echo "The site is the name of the directory your project is in."
return 1
fi
loc=0
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
then
SITE=$site
REMOTE=${REMOTES[$loc]}
break
fi
loc=$(($loc+1))
done
if [ -z "$SITE" ]
then
echo "No such site."
return 1
fi
builtin cd $SITE
rsync -rz $REMOTE
}

View File

@ -26,18 +26,6 @@ export NGINX_PATH='/opt/nginx'
# Don't check mail when opening terminal.
unset MAILCHECK
# Change this to the path of your local jekyll root to use the jekyll aliases
export JEKYLL_LOCAL_ROOT="$HOME/Sites/jekyllsite"
# And change this to the remote server and root
export JEKYLL_REMOTE_ROOT="user@server:/path/to/jekyll/root"
# And, for the last of the jekyll variables, this is the formatting you use, eg: markdown,
# textile, etc. Basically whatever you use as the extension for posts, without the preceding dot
export JEKYLL_FORMATTING="markdown"
# Change this to your console based IRC client of choice.

View File

@ -0,0 +1,17 @@
# This is a space-delimited list of your Jekyll project paths
SITES="$HOME/sites/project_1 $HOME/sites/project_2"
# This is another space-delimited list.
# This one is of the remote user@host:path location of your jekyll site
# NOTE: The locations of these must correspond to the locations
# of the sites in the first list
# For instance, the host for the first Jekyll site
# must be first in this list, the second second, etc.
REMOTES="user@host_1:path user@host_2:path"
# list of markup syntaxes to use for the sites,
# Same rules as above. Can be HTML, textile, or markdown
MARKUPS="markdown textile"

View File

@ -17,11 +17,12 @@ fi
doubletime_scm_prompt() {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]
then
if [ $CHAR = $SCM_NONE_CHAR ]; then
return
else
elif [ $CHAR = $SCM_GIT_CHAR ]; then
echo "$(git_prompt_status)"
else
echo "[$(scm_prompt_info)]"
fi
}

View File

@ -1,7 +1,12 @@
prompt_setter() {
PS1="${cyan}\W${normal} "
#!/usr/bin/env bash
SCM_THEME_PROMPT_PREFIX="${cyan}(${green}"
SCM_THEME_PROMPT_SUFFIX="${cyan})"
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${green}"
prompt() {
PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} "
}
PROMPT_COMMAND=prompt_setter
export PS3=">> "
PROMPT_COMMAND=prompt

View File

@ -0,0 +1,20 @@
#!/bin/bash
#
# Based on 'bobby' theme with the addition of virtualenv_prompt
#
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${green}"
SCM_THEME_PROMPT_PREFIX=" ${yellow}|${reset_color}"
SCM_THEME_PROMPT_SUFFIX="${yellow}|"
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|"
VIRTUALENV_THEME_PROMPT_PREFIX='|'
VIRTUALENV_THEME_PROMPT_SUFFIX='|'
function prompt_command() {
PS1="\n${green}$(virtualenv_prompt)${red}$(rvm_version_prompt) ${reset_color}\h ${orange}in ${reset_color}\w\n${yellow}$(scm_char)$(scm_prompt_info) ${yellow}${white} "
}
PROMPT_COMMAND=prompt_command;