Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
Added a set of fixes and new features.
  • Loading branch information
andrewwoods committed Apr 7, 2015
2 parents ea51538 + b45fdd0 commit 0fbbeb5
Show file tree
Hide file tree
Showing 12 changed files with 601 additions and 86 deletions.
6 changes: 2 additions & 4 deletions README.md
Expand Up @@ -87,7 +87,7 @@ characters one at a time, as if you typed it
PUNCH: keep track of when you start and stop working on things by writing to the timesheet.txt file. the included timecalc.php scripts parses the timesheet.txt file. Great for freelancers who track their time, and use tools like GetHarvest or Free Agent.

It's first argument can be 'in', 'out', 'note', or 'switch'
The second argument is only required for 'note'
The second argument is only *required* for 'note', but it's useful for keeping track of what you work on

$ punch in
$ punch in "type a brief message here"
Expand All @@ -96,11 +96,10 @@ The second argument is only required for 'note'
$ punch note "type a brief message here"
$ punch switch "type a brief message here"

For best results, add a note when you punch in. Include things like an issue number, client name, or project name and a few words about the task. I'd love to know what works for you.

SET_PROMPT: Allows you to easily change the values displayed in your prompt. Uses the parse_git_branch() function.



SHOW: display information about different types of info in the shell. the
output for each of the arguments depends on your system.

Expand Down Expand Up @@ -214,4 +213,3 @@ phpdoc codes have the formula 'x_' + name.
Take a look at the vimrc files to see everything it can do.



22 changes: 18 additions & 4 deletions bashrc
Expand Up @@ -61,6 +61,7 @@ alias bvi='vim -u ~/opal/vimrc_bash'
alias civi='vim -u ~/opal/vimrc_codeigniter'
alias druvi='vim -u ~/opal/vimrc_drupal'
alias rbvi='vim -u ~/opal/vimrc_ruby'
alias svi='vim -u ~/opal/vimrc_symfony'
alias wpvi='vim -u ~/opal/vimrc_wordpress'
alias zendvi='vim -u ~/opal/vimrc_zend'

Expand Down Expand Up @@ -116,13 +117,13 @@ function punch(){
elif [[ $1 == "switch" ]]; then
MESG=$DATESTAMP
MESG="$MESG OUT"
if [[ -n $2 ]]; then
MESG="$MESG $2"
fi
echo $MESG >> $DATADIR/timesheet.txt

MESG=$DATESTAMP
MESG="$MESG IN"
if [[ -n $2 ]]; then
MESG="$MESG $2"
fi
echo $MESG >> $DATADIR/timesheet.txt

else
Expand Down Expand Up @@ -411,7 +412,7 @@ function set_prompt()
full)
# andrewwoods@tardis.local ~/opal
# Sat Jan 18 22:37:10 [626]$
PS1="\n\u@\H \W\n\d \A[\!]\$(parse_git_branch)\$ "
PS1="\n\u@\H \W\n\d \t [\!]\$(parse_git_branch)\$ "
;;

compact)
Expand Down Expand Up @@ -717,4 +718,17 @@ function note(){
fi
}

#
# traceurl - decode a short url to it's final destination
#
#
function traceurl(){

if [[ -n $1 ]]
then
curl --location --head $1
else
echo 'Whoops! You forgot to specify a short URL'
fi
}

31 changes: 28 additions & 3 deletions help/snippets.txt
@@ -1,5 +1,5 @@

# display the lines 159 thru 170 of filename.txt
# display the lines 159 thru 170 of filename.txt
$ awk 'NR >= 159 && NR <= 170 ' filename.txt

# Same thing in SED
Expand All @@ -13,7 +13,7 @@ $ echo {one,two,red,blue}" fish"

# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
$ sed '/^$/d;G'
$ sed '/^$/d;G'

# In UNIX environment, Remove every ^M from text files
sed 's/^M$//g'
Expand All @@ -22,10 +22,35 @@ sed 's/^M$//g'
sed 's/[ \t]*$//'

# print only lines of 81 characters or longer
awk 'length > 80'
awk 'length > 80'

# search thru files and skip the .svn directories
find . -not \( -name .svn -prune \)

# Get a blueprint of PHP code - your function and classes with methods
# if 'ack' is not installed, use 'brew install ack'
# replace DIRECTORY with a real directory name
ack --recurse --type=php --with-filename '^\s*(class|(public )?(static )?function)' DIRECTORY

# Like the previous, but also finds required or included files. You'll want to write the results to a file
# due to high number of results
ack --recurse --type=php --with-filename '^\s*((require|include)(_once)?|class|(public )?(static )?function)' DIRECTORY



#
# Checking source code for quality
#

# Do lines begin with spaces?
ack --recurse --type=php --with-filename '^[ ]+(?!\*)' DIRNAME

# Do lines begin with tabs?
ack --recurse --type=php --with-filename '^\t+' DIRNAME

# check that developers included the phpdoc before their classes and functions
ack --recurse --type=php --with-filename -B 10 '^\s*(class|(public )?(static )?function)' DIRECTORY

# alt check that developers included the phpdoc before their classes and functions
ack --recurse --type=php --with-filename '(^\s*class|function [\w\d_]+\()' DIRECTORY

35 changes: 28 additions & 7 deletions help/vim-reference.txt
Expand Up @@ -161,8 +161,8 @@ CTRL+F, CTRL+B Scroll forward, backward one screen
CTRL+D, CTRL+U Scroll down, up one-half screen
CTRL+E, CTRL+Y Show one more line at bottom, top of window
zENTER Reposition line with cursor: to top of window
z. Reposition line with cursor: to middle of window
z- Reposition line with cursor: to bottom of window
z. Reposition line with cursor: to middle of window
z- Reposition line with cursor: to bottom of window
CTRL+L Redraw screen (without scrolling)

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -205,7 +205,7 @@ EDITING COMMANDS
Insert
--------------------------------------------------------------------------------

i, a Insert text before beginning, after cursor
i, a Insert text before beginning, after cursor
I, A Insert text before beginning, after end of line
o, O Open new line for text below, above cursor

Expand Down Expand Up @@ -274,7 +274,7 @@ BUFFERS
:bp[revious] Go to the previous buffer. (Mnemonic: buffer previous).
:bf[irst] Go to the first buffer.
:bl[ast] Go to the last buffer.
:ba[ll] Open all the buffers in the buffer list.
:ba[ll] Open all the buffers in the buffer list.


EXIT COMMANDS
Expand All @@ -284,19 +284,40 @@ EXIT COMMANDS
:wq Write (save) and quit file
:x Write (save) and quit file
ZZ Write (save) and quit file
:30,60w newfile Write from lines 30 through 60 as newfile
:30,60w>> newfile Write from lines 30 through 60 and append to newfile
:30,60w newfile Write from lines 30 through 60 as newfile
:30,60w>> newfile Write from lines 30 through 60 and append to newfile
:w %.new Write current named file as file.new
:q Quit file
:q! Quit file, overriding protection
Q Quit vi and envoke ex

NAME THIS
================================================================================
:e file2 Edit file2 without leaving vi
:e! Return to version of current file as of time of last write file
:vi Invoke vi editor from ex
:vi Invoke vi editor from ex
: Invoke one ex command from vi editor
% Current filename (substitutes into ex command line)
# Alternate filename (substitutes into ex command line)
:ls List buffers
:bdn Delete buffer n (n is the buffer number from :ls)


NOTES FROM designbytyping.com (Vim Project)
================================================================================
^0 - goes to previous location in jumplist

:e . open a directory selection window for current directory
:sp file open a horizontal split
:vsp file open a file in a vertical split

can use tab to cycle through file names when trying to edit a file

^W l moves your cursor to the split on the right
^W h moves your cursor to the split on the left
^W k moves your cursor up a split
^W j moves your cursor down a split

^W w moves your cursor to the next window in a clockwise motion
^W H Change Horizontal split to a Vertical split
^W J Change Vertical split to a Horizontal split
2 changes: 1 addition & 1 deletion timecalc.php
Expand Up @@ -108,7 +108,7 @@
$timeDecimal = round($hours + $decimal, 2);

$total_time += $timeDecimal;
printf(" %s %s %s hours ( %s ): %s\n", $date, $day, $timeDecimal, $interval->format("%H hours %I minutes"), $message);
printf(" %s %s %s hours ( %s ): %s\n", $date, $day, $timeDecimal, $interval->format("%H hours %I minutes"), $task);
}

if ($op == 'NOTE')
Expand Down
111 changes: 111 additions & 0 deletions vim_functions/edit.vim
@@ -0,0 +1,111 @@
"
" Any files ending in .php will be syntax checked when saving
"
function CheckPhpSyntax()
let current_file = shellescape(expand('%:p'))
let command = '!php --syntax-check ' . current_file
execute command
endfunction
autocmd BufWritePost,FileWritePost *.php call CheckPhpSyntax()

"
" @todo Figure out how to add the tab level to the current status line
" without overwriting it entirely
"
" set statusline=\t%{ShowTab()}\ %P
"
function ShowTab()
let TabLevel = (indent('.') / &ts )
if TabLevel == 0
let TabLevel='*'
endif
return TabLevel
endfunction

"
" Description: Per buffer, togglable syntax highlighting of tabs and trailing
" spaces.
" Author: Adam Lazur <adam@lazur.org>
" Last Change: $Date: 2002/10/11 20:37:13 $
" URL: http://adam.lazur.org/vim/spacehi.vim
" License: Redistribution and use of this file, with or without
" modification, are permitted without restriction.
"
"
" This plugin will highlight tabs and trailing spaces on a line, with the
" ability to toggle the highlighting on and off. Using highlighting to
" illuminate these characters is preferrable to using listchars and set list
" because it allows you to copy from the vim window without getting shrapnel
" in your buffer.
"
" NOTE: "set list" will override SpaceHi's highlighting.
"
" Highlighting can be turned on and off with the functions SpaceHi() and
" NoSpaceHi() respectively. You can also toggle the highlighting state by
" using ToggleSpaceHi(). By default, ToggleSpaceHi is bound to the key F3.
"

if exists("loaded_spacehi")
finish
endif
let loaded_spacehi=1

" Section: Default Global Vars
if !exists("g:spacehi_tabcolor")
" highlight tabs with red underline
" let g:spacehi_tabcolor="ctermfg=1 cterm=underline"
" let g:spacehi_tabcolor=g:spacehi_tabcolor . " guifg=blue gui=underline"
endif
if !exists("g:spacehi_spacecolor")
" highlight trailing spaces in blue underline
let g:spacehi_spacecolor="ctermfg=white ctermbg=red "
let g:spacehi_spacecolor=g:spacehi_spacecolor . " guifg=white guibg=red"
endif

"
" Turn on highlighting of spaces and tabs
"
function! s:SpaceHi()
" highlight tabs
" syntax match spacehiTab /\t/ containedin=ALL
" execute("highlight spacehiTab " . g:spacehi_tabcolor)

" highlight trailing spaces
syntax match spacehiTrailingSpace /\s\+$/ containedin=ALL
execute("highlight spacehiTrailingSpace " . g:spacehi_spacecolor)

let b:spacehi = 1
endfunction

"
" Turn off highlighting of spaces and tabs
"
function! s:NoSpaceHi()
" syntax clear spacehiTab
syntax clear spacehiTrailingSpace
let b:spacehi = 0
endfunction

" Function: s:ToggleSpaceHi()
" Toggle highlighting of spaces and tabs
function! s:ToggleSpaceHi()
if exists("b:spacehi") && b:spacehi
call s:NoSpaceHi()
echo "spacehi off"
else
call s:SpaceHi()
echo "spacehi on"
endif
endfunction

" Section: Commands
com! SpaceHi call s:SpaceHi()
com! NoSpaceHi call s:NoSpaceHi()
com! ToggleSpaceHi call s:ToggleSpaceHi()

" Section: Default mappings
" Only insert a map to ToggleSpaceHi if they don't already have a map to
" the function and don't have something bound to F3
if !hasmapto('ToggleSpaceHi') && maparg("<F3>") == ""
map <silent> <unique> <F3> :ToggleSpaceHi<CR>
endif
25 changes: 25 additions & 0 deletions vim_functions/search.vim
@@ -0,0 +1,25 @@
" This rewires n and N to do the highlighing...
nnoremap <silent> n n:call HLNext(0.6)<cr>
nnoremap <silent> N N:call HLNext(0.6)<cr>
" highlight the match in magenta...
function! HLNext (blinktime)
highlight WhiteOnDarkMagenta ctermfg=white ctermbg=DarkMagenta
let [bufnum, lnum, col, off] = getpos('.')
let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
let target_pat = '\c\%#\%('.@/.'\)'
let ring = matchadd('WhiteOnDarkMagenta', target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
call matchdelete(ring)
redraw
endfunction

function! ListFunctions()
exec 'grep function %'
endfunction

" com! ToggleSpaceHi call s:ToggleSpaceHi()

" map <silent> <unique> <F4> :ListFunctions<CR>

0 comments on commit 0fbbeb5

Please sign in to comment.