Merge
commit
b1df1ab0fe
|
|
@ -1,6 +1,6 @@
|
||||||
# Bash it
|
# Bash it
|
||||||
|
|
||||||
'Bash it' is a mash up of my own bash commands and scripts, other bash stuff I have found and a shameless ripoff of oh-my-zsh. :)
|
'Bash it' is a mash up of my own bash commands and scripts, other bash stuff I have found and a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh). :)
|
||||||
|
|
||||||
Includes some autocompletion tools, theming support, aliases, custom functions, a few stolen pieces from Steve Losh, and more.
|
Includes some autocompletion tools, theming support, aliases, custom functions, a few stolen pieces from Steve Losh, and more.
|
||||||
|
|
||||||
|
|
@ -47,4 +47,4 @@ So, if you have contributions to bash-it, please send me a pull request and I'll
|
||||||
|
|
||||||
* [List of contributors][contribute]
|
* [List of contributors][contribute]
|
||||||
|
|
||||||
[contribute]: https://github.com/revans/bash-it/contributors
|
[contribute]: https://github.com/revans/bash-it/contributors
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ alias q="exit"
|
||||||
|
|
||||||
alias irc="$IRC_CLIENT"
|
alias irc="$IRC_CLIENT"
|
||||||
|
|
||||||
|
alias rb="ruby"
|
||||||
|
|
||||||
# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/
|
# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/
|
||||||
|
|
||||||
alias piano="pianobar"
|
alias piano="pianobar"
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ alias gpo='git push origin'
|
||||||
alias gdv='git diff -w "$@" | vim -R -'
|
alias gdv='git diff -w "$@" | vim -R -'
|
||||||
alias gc='git commit -v'
|
alias gc='git commit -v'
|
||||||
alias gca='git commit -v -a'
|
alias gca='git commit -v -a'
|
||||||
|
alias gci='git commit --interactive'
|
||||||
alias gb='git branch'
|
alias gb='git branch'
|
||||||
alias gba='git branch -a'
|
alias gba='git branch -a'
|
||||||
alias gcount='git shortlog -sn'
|
alias gcount='git shortlog -sn'
|
||||||
|
|
@ -23,6 +24,8 @@ alias gcp='git cherry-pick'
|
||||||
alias gco='git checkout'
|
alias gco='git checkout'
|
||||||
alias gexport='git archive --format zip --output'
|
alias gexport='git archive --format zip --output'
|
||||||
alias gdel='git branch -D'
|
alias gdel='git branch -D'
|
||||||
|
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master'
|
||||||
|
alias gll='git log --graph --pretty=oneline --abbrev-commit'
|
||||||
|
|
||||||
case $OSTYPE in
|
case $OSTYPE in
|
||||||
linux*)
|
linux*)
|
||||||
|
|
@ -55,13 +58,16 @@ function git-help() {
|
||||||
echo " gdv = git diff -w \"$@\" | vim -R -"
|
echo " gdv = git diff -w \"$@\" | vim -R -"
|
||||||
echo " gc = git commit -v"
|
echo " gc = git commit -v"
|
||||||
echo " gca = git commit -v -a"
|
echo " gca = git commit -v -a"
|
||||||
|
echo " gci = git commit --interactive"
|
||||||
echo " gb = git branch"
|
echo " gb = git branch"
|
||||||
echo " gba = git branch -a"
|
echo " gba = git branch -a"
|
||||||
echo " gcount = git shortlog -sn"
|
echo " gcount = git shortlog -sn"
|
||||||
echo " gcp = git cherry-pick"
|
echo " gcp = git cherry-pick"
|
||||||
echo " gco = git checkout"
|
echo " gco = git checkout"
|
||||||
echo " gexport = git git archive --format zip --output"
|
echo " gexport = git git archive --format zip --output"
|
||||||
echo " gdel = git branch -D"
|
echo " gdel = git branch -D"
|
||||||
echo " gpo = git push origin"
|
echo " gpo = git push origin"
|
||||||
|
echo " gmu = git fetch origin -v; git fetch upstream -v; git merge upstream/master"
|
||||||
|
echo " gll = git log --graph --pretty=oneline --abbrev-commit"
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,9 @@ done
|
||||||
|
|
||||||
|
|
||||||
unset config_file
|
unset config_file
|
||||||
export PS1=$PROMPT
|
if [[ $PROMPT ]]; then
|
||||||
|
export PS1=$PROMPT
|
||||||
|
fi
|
||||||
|
|
||||||
# Adding Support for other OSes
|
# Adding Support for other OSes
|
||||||
PREVIEW="less"
|
PREVIEW="less"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Bash completion support for ssh.
|
||||||
|
|
||||||
|
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
|
||||||
|
|
||||||
|
_sshcomplete() {
|
||||||
|
|
||||||
|
# parse all defined hosts from .ssh/config
|
||||||
|
if [ -r $HOME/.ssh/config ]; then
|
||||||
|
COMPREPLY=($(compgen -W "$(grep ^Host $HOME/.ssh/config | awk '{print $2}' )" -- ${COMP_WORDS[COMP_CWORD]}))
|
||||||
|
fi
|
||||||
|
|
||||||
|
# parse all hosts found in .ssh/known_hosts
|
||||||
|
if [ -r $HOME/.ssh/known_hosts ]; then
|
||||||
|
if grep -v -q -e '^ ssh-rsa' $HOME/.ssh/known_hosts ; then
|
||||||
|
COMPREPLY=( $COMPREPLY $(compgen -W "$( awk '{print $1}' $HOME/.ssh/known_hosts | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" -- ${COMP_WORDS[COMP_CWORD]} ))
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -o default -o nospace -F _sshcomplete ssh
|
||||||
|
|
@ -8,4 +8,6 @@ export GREP_COLOR='1;33'
|
||||||
export LSCOLORS='Gxfxcxdxdxegedabagacad'
|
export LSCOLORS='Gxfxcxdxdxegedabagacad'
|
||||||
|
|
||||||
# Load the theme
|
# Load the theme
|
||||||
source "$BASH/themes/$BASH_THEME/$BASH_THEME.theme.bash"
|
if [[ $BASH_THEME ]]; then
|
||||||
|
source "$BASH/themes/$BASH_THEME/$BASH_THEME.theme.bash"
|
||||||
|
fi
|
||||||
|
|
@ -30,6 +30,10 @@ pri() {
|
||||||
ri -T "${1}" | open -f -a $PREVIEW
|
ri -T "${1}" | open -f -a $PREVIEW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quiet() {
|
||||||
|
$* &> /dev/null &
|
||||||
|
}
|
||||||
|
|
||||||
banish-cookies() {
|
banish-cookies() {
|
||||||
rm -r ~/.macromedia ~/.adobe
|
rm -r ~/.macromedia ~/.adobe
|
||||||
ln -s /dev/null ~/.adobe
|
ln -s /dev/null ~/.adobe
|
||||||
|
|
@ -83,4 +87,10 @@ function plugins-help() {
|
||||||
| grep -v "COMPREPLY=()" | sed -e "s/()//"
|
| grep -v "COMPREPLY=()" | sed -e "s/()//"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# back up file with timestamp
|
||||||
|
# useful for administrators and configs
|
||||||
|
buf () {
|
||||||
|
filename=$1
|
||||||
|
filetime=$(date +%Y%m%d_%H%M%S)
|
||||||
|
cp ${filename} ${filename}_${filetime}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,40 @@ function git_remove_missing_files() {
|
||||||
# Adds files to git's exclude file (same as .gitignore)
|
# Adds files to git's exclude file (same as .gitignore)
|
||||||
function local-ignore() {
|
function local-ignore() {
|
||||||
echo "$1" >> .git/info/exclude
|
echo "$1" >> .git/info/exclude
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# get a quick overview for your git repo
|
||||||
|
function git_info() {
|
||||||
|
if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
|
||||||
|
# print informations
|
||||||
|
echo "git repo overview"
|
||||||
|
echo "-----------------"
|
||||||
|
echo
|
||||||
|
|
||||||
|
# print all remotes and thier details
|
||||||
|
for remote in $(git remote show); do
|
||||||
|
echo $remote:
|
||||||
|
git remote show $remote
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
|
||||||
|
# print status of working repo
|
||||||
|
echo "status:"
|
||||||
|
if [ -n "$(git status -s 2> /dev/null)" ]; then
|
||||||
|
git status -s
|
||||||
|
else
|
||||||
|
echo "working directory is clean"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# print at least 5 last log entries
|
||||||
|
echo
|
||||||
|
echo "log:"
|
||||||
|
git log -5 --oneline
|
||||||
|
echo
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "you're currently not in a git repository"
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# hcht.plugin.bash: the handmade commandline history tool
|
||||||
|
# Copyright: (C) 2010 Florian Baumann <flo@noqqe.de>
|
||||||
|
# License: GPL-3 <http://www.gnu.org/licenses/gpl-3.0.txt>
|
||||||
|
# Date: Dienstag 2010-11-30
|
||||||
|
|
||||||
|
### readme
|
||||||
|
# basiclly the handmade commandline history tool was made for storing
|
||||||
|
# informations. yeah, you're right. sounds a bit boring. many other
|
||||||
|
# applications can do this much better. but storing things from commandline?
|
||||||
|
#
|
||||||
|
# hcht was fitted to work at your terminal.
|
||||||
|
# your daily stuff like notices, todos, commands or output from a command.
|
||||||
|
# all these things will be stored without complex syntax.
|
||||||
|
#
|
||||||
|
# once you defined your storing-directory you will be able to easily
|
||||||
|
# save all the stuff listed above.
|
||||||
|
#
|
||||||
|
|
||||||
|
### create a file
|
||||||
|
# the basic feature. open a file, do stuff and save.
|
||||||
|
#
|
||||||
|
# $ hcht evilcommand.hch
|
||||||
|
#
|
||||||
|
# this will create a new file or edit a existing one.
|
||||||
|
# paste your command or notice in your favorite editor
|
||||||
|
|
||||||
|
### show all stored informations
|
||||||
|
# to get an overview of your storedir:
|
||||||
|
#
|
||||||
|
# $ hcht
|
||||||
|
|
||||||
|
### todo with a whole sentence
|
||||||
|
# you can give hcht a bunch of parameters
|
||||||
|
#
|
||||||
|
# $ hcht this is a long reminder about a anything
|
||||||
|
|
||||||
|
### save last executed command
|
||||||
|
# lets say you did a great hack at your system and you
|
||||||
|
# want to save it without complicated use of coping:
|
||||||
|
#
|
||||||
|
# $ hcht !!
|
||||||
|
#
|
||||||
|
# the "!!" will repeat the _last_ command you executed at
|
||||||
|
# your terminal. after asking you about a name the hch file
|
||||||
|
# will be saved.
|
||||||
|
|
||||||
|
### read from stdin
|
||||||
|
# hcht is also able to read anything from stdin.
|
||||||
|
#
|
||||||
|
# $ cat any_important_logfile | hcht anylog
|
||||||
|
#
|
||||||
|
# "anylog" will be the name of the saved file.
|
||||||
|
|
||||||
|
hcht() {
|
||||||
|
# configured?
|
||||||
|
if [ -z $hchtstoredir ]; then
|
||||||
|
echo "ERROR: handmade commandline history tool isn't configured."
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
hchtstoredir=$(echo $hchtstoredir | sed -e 's/\/$//')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# dir available?
|
||||||
|
if [ ! -d $hchtstoredir ]; then
|
||||||
|
echo "ERROR: No such directory: $hchtstoredir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get favorite editor
|
||||||
|
if [ -z $EDITOR ]; then
|
||||||
|
EDITOR=$(which vim || which nano)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if stdin-data is present and save content
|
||||||
|
if [ "$(tty)" = "not a tty" ]; then
|
||||||
|
hchname=$(echo $1 | sed -e 's/\ //g')
|
||||||
|
if [ -z $hchname ]; then
|
||||||
|
cat < /dev/stdin >> $hchtstoredir/$(date +%Y%m%d%H%M%S).hch
|
||||||
|
else
|
||||||
|
cat < /dev/stdin >> $hchtstoredir/$hchname.hch
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# list all hch files if no parameter is given
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
for file in $(ls $hchtstoredir); do
|
||||||
|
echo $file
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if a *.hch file is given start editing or creating it
|
||||||
|
if [ "$#" -eq "1" ]; then
|
||||||
|
if echo "$1" | grep -q -e ".*.hch$" ; then
|
||||||
|
$EDITOR ${hchtstoredir}/${1}
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
$EDITOR ${hchtstoredir}/${1}.hch
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# autocreate a new hch
|
||||||
|
if [ "$#" -gt "1" ]; then
|
||||||
|
echo -n "define a name: " ; read hchname
|
||||||
|
hchname=$(echo $hchname | sed -e 's/\ /_/g')
|
||||||
|
if [ -z "$hchname" ]; then
|
||||||
|
echo "$*" > $hchtstoredir/${1}-$(date +%Y%m%d%H%M%S).hch
|
||||||
|
else
|
||||||
|
echo "$*" > ${hchtstoredir}/${hchname}.hch
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,31 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
editpost() {
|
||||||
|
builtin cd "$JEKYLL_LOCAL_ROOT/_posts"
|
||||||
|
|
||||||
|
COUNTER=1
|
||||||
|
NUMBER="$RANDOM"
|
||||||
|
TMPFILE="/tmp/editpost-$NUMBER"
|
||||||
|
|
||||||
|
for POST in *
|
||||||
|
do
|
||||||
|
DATE=`echo $POST | grep -oE "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}"`
|
||||||
|
TITLE=`cat $POST | grep -oE "title: (.+)"`
|
||||||
|
TITLE=`echo $TITLE | sed 's/title: //'`
|
||||||
|
echo "$COUNTER) $DATE $TITLE" >> "$TMPFILE"
|
||||||
|
POSTS[$COUNTER]=$POST
|
||||||
|
COUNTER=`expr $COUNTER + 1`
|
||||||
|
done
|
||||||
|
less $TMPFILE
|
||||||
|
read -p "Number of post to edit: " POST_TO_EDIT
|
||||||
|
if [ -z "$EDITOR" ]
|
||||||
|
then
|
||||||
|
nano "${POSTS[$POST_TO_EDIT]}"
|
||||||
|
else
|
||||||
|
"$EDITOR" "${POSTS[$POST_TO_EDIT]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
newpost() {
|
newpost() {
|
||||||
|
|
||||||
# 'builtin cd' into the local jekyll root
|
# 'builtin cd' into the local jekyll root
|
||||||
|
|
@ -12,7 +38,7 @@ newpost() {
|
||||||
|
|
||||||
# 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 formatting, let them choose what type of post they want. Sort of like Tumblr.
|
||||||
|
|
||||||
OPTIONS="Text Quote Image Audio Video"
|
OPTIONS="Text Quote Image Audio Video Link"
|
||||||
|
|
||||||
if [ $JEKYLL_FORMATTING = "markdown" -o $JEKYLL_FORMATTING = "textile" ]
|
if [ $JEKYLL_FORMATTING = "markdown" -o $JEKYLL_FORMATTING = "textile" ]
|
||||||
then
|
then
|
||||||
|
|
@ -47,6 +73,12 @@ newpost() {
|
||||||
POST_TYPE="Video"
|
POST_TYPE="Video"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $OPTION = "Link" ]]
|
||||||
|
then
|
||||||
|
POST_TYPE="Link"
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -122,6 +154,15 @@ newpost() {
|
||||||
then
|
then
|
||||||
echo "<html><video src=\"/path/to/video\" controls=\"controls\"></video></html>" >> $FNAME
|
echo "<html><video src=\"/path/to/video\" controls=\"controls\"></video></html>" >> $FNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $POST_TYPE = "Link" ]]
|
||||||
|
then
|
||||||
|
echo "[link][1]" >> $FNAME
|
||||||
|
echo >> $FNAME
|
||||||
|
echo "> Quote" >> $FNAME
|
||||||
|
echo >> $FNAME
|
||||||
|
echo "[1]: url" >> $FNAME
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $JEKYLL_FORMATTING = "textile" ]]
|
if [[ $JEKYLL_FORMATTING = "textile" ]]
|
||||||
|
|
@ -152,6 +193,13 @@ newpost() {
|
||||||
then
|
then
|
||||||
echo "<html><video src=\"/path/to/video\" controls=\"controls\"></video></html>" >> $FNAME
|
echo "<html><video src=\"/path/to/video\" controls=\"controls\"></video></html>" >> $FNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $POST_TYPE = "Link" ]]
|
||||||
|
then
|
||||||
|
echo "\"Site\":url" >> $FNAME
|
||||||
|
echo >> $FNAME
|
||||||
|
echo "bq. Quote" >> $FNAME
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Open the file in your favorite editor
|
# Open the file in your favorite editor
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
alias http='python -m SimpleHTTPServer'
|
||||||
|
|
||||||
|
|
@ -0,0 +1,148 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# maintains a jump-list of the directories you actually use
|
||||||
|
#
|
||||||
|
# INSTALL:
|
||||||
|
# * put something like this in your .bashrc:
|
||||||
|
# . /path/to/z.sh
|
||||||
|
# * cd around for a while to build up the db
|
||||||
|
# * PROFIT!!
|
||||||
|
#
|
||||||
|
# USE:
|
||||||
|
# * z foo # goes to most frecent dir matching foo
|
||||||
|
# * z foo bar # goes to most frecent dir matching foo and bar
|
||||||
|
# * z -r foo # goes to highest ranked dir matching foo
|
||||||
|
# * z -t foo # goes to most recently accessed dir matching foo
|
||||||
|
# * z -l foo # list all dirs matching foo (by frecency)
|
||||||
|
|
||||||
|
z() {
|
||||||
|
local datafile="$HOME/.z"
|
||||||
|
if [ "$1" = "--add" ]; then
|
||||||
|
# add
|
||||||
|
shift
|
||||||
|
# $HOME isn't worth matching
|
||||||
|
[ "$*" = "$HOME" ] && return
|
||||||
|
awk -v p="$*" -v t="$(date +%s)" -F"|" '
|
||||||
|
BEGIN { rank[p] = 1; time[p] = t }
|
||||||
|
$2 >= 1 {
|
||||||
|
if( $1 == p ) {
|
||||||
|
rank[$1] = $2 + 1
|
||||||
|
time[$1] = t
|
||||||
|
} else {
|
||||||
|
rank[$1] = $2
|
||||||
|
time[$1] = $3
|
||||||
|
}
|
||||||
|
count += $2
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
if( count > 1000 ) {
|
||||||
|
for( i in rank ) print i "|" 0.9*rank[i] "|" time[i] # aging
|
||||||
|
} else for( i in rank ) print i "|" rank[i] "|" time[i]
|
||||||
|
}
|
||||||
|
' "$datafile" 2>/dev/null > "$datafile.tmp"
|
||||||
|
mv -f "$datafile.tmp" "$datafile"
|
||||||
|
elif [ "$1" = "--complete" ]; then
|
||||||
|
# tab completion
|
||||||
|
awk -v q="$2" -F"|" '
|
||||||
|
BEGIN {
|
||||||
|
if( q == tolower(q) ) nocase = 1
|
||||||
|
split(substr(q,3),fnd," ")
|
||||||
|
}
|
||||||
|
{
|
||||||
|
if( system("test -d \"" $1 "\"") ) next
|
||||||
|
if( nocase ) {
|
||||||
|
for( i in fnd ) tolower($1) !~ tolower(fnd[i]) && $1 = ""
|
||||||
|
if( $1 ) print $1
|
||||||
|
} else {
|
||||||
|
for( i in fnd ) $1 !~ fnd[i] && $1 = ""
|
||||||
|
if( $1 ) print $1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' "$datafile" 2>/dev/null
|
||||||
|
else
|
||||||
|
# list/go
|
||||||
|
while [ "$1" ]; do case "$1" in
|
||||||
|
-h) echo "z [-h][-l][-r][-t] args" >&2; return;;
|
||||||
|
-l) local list=1;;
|
||||||
|
-r) local typ="rank";;
|
||||||
|
-t) local typ="recent";;
|
||||||
|
--) while [ "$1" ]; do shift; local fnd="$fnd $1";done;;
|
||||||
|
*) local fnd="$fnd $1";;
|
||||||
|
esac; local last=$1; shift; done
|
||||||
|
[ "$fnd" ] || local list=1
|
||||||
|
# if we hit enter on a completion just go there
|
||||||
|
[ -d "$last" ] && cd "$last" && return
|
||||||
|
[ -f "$datafile" ] || return
|
||||||
|
local cd="$(awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -v tmpfl="$datafile.tmp" -F"|" '
|
||||||
|
function frecent(rank, time) {
|
||||||
|
dx = t-time
|
||||||
|
if( dx < 3600 ) return rank*4
|
||||||
|
if( dx < 86400 ) return rank*2
|
||||||
|
if( dx < 604800 ) return rank/2
|
||||||
|
return rank/4
|
||||||
|
}
|
||||||
|
function output(files, toopen, override) {
|
||||||
|
if( list ) {
|
||||||
|
if( typ == "recent" ) {
|
||||||
|
cmd = "sort -nr >&2"
|
||||||
|
} else cmd = "sort -n >&2"
|
||||||
|
for( i in files ) if( files[i] ) printf "%-10s %s\n", files[i], i | cmd
|
||||||
|
if( override ) printf "%-10s %s\n", "common:", override > "/dev/stderr"
|
||||||
|
} else {
|
||||||
|
if( override ) toopen = override
|
||||||
|
print toopen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function common(matches, fnd, nc) {
|
||||||
|
for( i in matches ) {
|
||||||
|
if( matches[i] && (!short || length(i) < length(short)) ) short = i
|
||||||
|
}
|
||||||
|
if( short == "/" ) return
|
||||||
|
for( i in matches ) if( matches[i] && i !~ short ) x = 1
|
||||||
|
if( x ) return
|
||||||
|
if( nc ) {
|
||||||
|
for( i in fnd ) if( tolower(short) !~ tolower(fnd[i]) ) x = 1
|
||||||
|
} else for( i in fnd ) if( short !~ fnd[i] ) x = 1
|
||||||
|
if( !x ) return short
|
||||||
|
}
|
||||||
|
BEGIN { split(q, a, " ") }
|
||||||
|
{
|
||||||
|
if( system("test -d \"" $1 "\"") ) next
|
||||||
|
print $0 >> tmpfl
|
||||||
|
if( typ == "rank" ) {
|
||||||
|
f = $2
|
||||||
|
} else if( typ == "recent" ) {
|
||||||
|
f = t-$3
|
||||||
|
} else f = frecent($2, $3)
|
||||||
|
wcase[$1] = nocase[$1] = f
|
||||||
|
for( i in a ) {
|
||||||
|
if( $1 !~ a[i] ) delete wcase[$1]
|
||||||
|
if( tolower($1) !~ tolower(a[i]) ) delete nocase[$1]
|
||||||
|
}
|
||||||
|
if( wcase[$1] > oldf ) {
|
||||||
|
cx = $1
|
||||||
|
oldf = wcase[$1]
|
||||||
|
} else if( nocase[$1] > noldf ) {
|
||||||
|
ncx = $1
|
||||||
|
noldf = nocase[$1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
if( cx ) {
|
||||||
|
output(wcase, cx, common(wcase, a, 0))
|
||||||
|
} else if( ncx ) output(nocase, ncx, common(nocase, a, 1))
|
||||||
|
}
|
||||||
|
' "$datafile")"
|
||||||
|
if [ $? -gt 0 ]; then
|
||||||
|
rm -f "$datafile.tmp"
|
||||||
|
else
|
||||||
|
mv -f "$datafile.tmp" "$datafile"
|
||||||
|
[ "$cd" ] && cd "$cd"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
# tab completion
|
||||||
|
complete -C 'z --complete "$COMP_LINE"' z
|
||||||
|
# populate directory list. avoid clobbering other PROMPT_COMMANDs.
|
||||||
|
echo $PROMPT_COMMAND | grep -q "z --add"
|
||||||
|
[ $? -gt 0 ] && PROMPT_COMMAND='z --add "$(pwd -P)";'"$PROMPT_COMMAND"
|
||||||
|
|
@ -47,5 +47,8 @@ export IRC_CLIENT='irssi'
|
||||||
|
|
||||||
export TODO="t"
|
export TODO="t"
|
||||||
|
|
||||||
|
# Set store directory for handmade commandline history tool
|
||||||
|
export hchtstoredir="$HOME/.hcht"
|
||||||
|
|
||||||
# Load Bash It
|
# Load Bash It
|
||||||
source $BASH/bash_it.sh
|
source $BASH/bash_it.sh
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ function prompt_char {
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt_info {
|
function git_prompt_info {
|
||||||
if [[ -n $(git status -s 2> /dev/null) ]]; then
|
if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then
|
||||||
state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
|
state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
|
||||||
else
|
else
|
||||||
state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
|
state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
|
||||||
|
|
@ -81,4 +81,4 @@ function rvm_version_prompt {
|
||||||
rvm=$(rvm tools identifier) || return
|
rvm=$(rvm tools identifier) || return
|
||||||
echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX"
|
echo -e "$RVM_THEME_PROMPT_PREFIX$rvm$RVM_THEME_PROMPT_SUFFIX"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,18 @@
|
||||||
prompt_setter() {
|
prompt_setter() {
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
PS1="\W "
|
if [ ! $VIMRUNTIME = "" ]
|
||||||
|
then
|
||||||
|
PS1="{vim} \W "
|
||||||
|
else
|
||||||
|
PS1="\W "
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
PS1="${bold_red}\W ${normal}"
|
if [ ! $VIMRUNTIME = "" ]
|
||||||
|
then
|
||||||
|
PS1="{vim} ${bold_red}\W ${normal}"
|
||||||
|
else
|
||||||
|
PS1="${bold_red}\W ${normal}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
SCM_THEME_PROMPT_PREFIX=""
|
||||||
|
SCM_THEME_PROMPT_SUFFIX=""
|
||||||
|
|
||||||
|
SCM_THEME_PROMPT_DIRTY=' ${bold_red}✗${normal}'
|
||||||
|
SCM_THEME_PROMPT_CLEAN=' ${bold_green}✓${normal}'
|
||||||
|
SCM_GIT_CHAR='${bold_green}±${normal}'
|
||||||
|
SCM_SVN_CHAR='${bold_cyan}⑆${normal}'
|
||||||
|
SCM_HG_CHAR='${bold_red}☿${normal}'
|
||||||
|
|
||||||
|
PS3=">> "
|
||||||
|
|
||||||
|
is_vim_shell() {
|
||||||
|
if [ ! -z "$VIMRUNTIME" ]
|
||||||
|
then
|
||||||
|
echo "[${cyan}vim shell${normal}]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
modern_scm_prompt() {
|
||||||
|
CHAR=$(scm_char)
|
||||||
|
if [ $CHAR = $SCM_NONE_CHAR ]
|
||||||
|
then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
echo "[$(scm_char)][$(scm_prompt_info)]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt() {
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
then
|
||||||
|
# Yes, the indenting on these is weird, but it has to be like
|
||||||
|
# this otherwise it won't display properly.
|
||||||
|
|
||||||
|
PS1="${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}]$(is_vim_shell)
|
||||||
|
${bold_red}└─▪${normal} "
|
||||||
|
else
|
||||||
|
PS1="┌─$(modern_scm_prompt)[${cyan}\W${normal}]$(is_vim_shell)
|
||||||
|
└─▪ "
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
PS2="└─▪ "
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PROMPT_COMMAND=prompt
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# n0qorg theme by Florian Baumann <flo@noqqe.de>
|
||||||
|
|
||||||
|
## look-a-like
|
||||||
|
# host directory (branch*)»
|
||||||
|
# for example:
|
||||||
|
# ananas ~/Code/bash-it/themes (master*)»
|
||||||
|
PROMPT="${bold_blue}\[\$(hostname)\]${normal} \w${normal} ${bold_white}\[\$(git_prompt_info)\]${normal}» "
|
||||||
|
|
||||||
|
## git-theme
|
||||||
|
# feel free to change git chars.
|
||||||
|
GIT_THEME_PROMPT_DIRTY="${bold_blue}*${bold_white}"
|
||||||
|
GIT_THEME_PROMPT_CLEAN=""
|
||||||
|
GIT_THEME_PROMPT_PREFIX="${bold_blue}(${bold_white}"
|
||||||
|
GIT_THEME_PROMPT_SUFFIX="${bold_blue})"
|
||||||
|
|
||||||
|
## alternate chars
|
||||||
|
#
|
||||||
|
SCM_THEME_PROMPT_DIRTY="*"
|
||||||
|
SCM_THEME_PROMPT_CLEAN=""
|
||||||
|
SCM_THEME_PROMPT_PREFIX="("
|
||||||
|
SCM_THEME_PROMPT_SUFFIX=")"
|
||||||
Loading…
Reference in New Issue