Created
July 31, 2013 07:08
-
-
Save bamanzi/6119940 to your computer and use it in GitHub Desktop.
Add grep/ack/grin to SciTE(-ru)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Note: for scite.ShowParametersDialog, you need SciTE-ru (http://scite-ru.googlecode.com ) | |
| ## and original SciTE allows only up to 50 commands (while SciTE-ru allows 300) | |
| ## on original SciTE, you can add this: | |
| #command.name.260.*=Grep in current file... | |
| #command.mode.260.*=subsystem:console,savebefore:no | |
| #command.26.*=grep --line-number --with-filename "$(CurrentSelection)" "$(FileNameExt)" | |
| ##or: | |
| #command.26.*=*grep --line-number --with-filename "$(1)" "$(2)" | |
| command.name.260.*=Grep in current file... | |
| command.mode.260.*=subsystem:lua,savebefore:no | |
| ;;command.260.*=grep --line-number --with-filename "$(CurrentSelection)" $(FileNameExt) | |
| command.260.*=dostring \ | |
| local function command_output(cmd) \ | |
| local tempfile = os.getenv('TMP') .. '\\scite_temp1' \ | |
| os.execute(cmd .. ' > ' .. tempfile) \ | |
| local h = io.open(tempfile) \ | |
| result = '' \ | |
| if h then \ | |
| result = h:read('*a') \ | |
| h:close() \ | |
| end \ | |
| return result \ | |
| end \ | |
| props['1']=(props['CurrentSelection']=='' and props['CurrentWord'] or props['CurrentSelection']) \ | |
| FIXME = "props['2']= '*.' .. props['FileExt'] -- no os.setcwd(?) in lua/scite?" \ | |
| props['2']=props['FileDir'] .. '\\*.' .. props['FileExt'] \ | |
| if scite.ShowParametersDialog('grep --line-number --with-filename $1 $2') then \ | |
| cmd = string.format('grep -nH "%s" "%s"', props['1'], props['2']) \ | |
| print('> ' .. cmd) \ | |
| print(command_output(cmd)) \ | |
| end | |
| command.shortcut.260.*=Alt+O | |
| IDU_GREP_IN_THIS_FILE=9260 | |
| command.name.261.*=Grep in files... | |
| command.mode.261.*=subsystem:lua,savebefore:no | |
| ;;command.261.*=grep --line-number --with-filename "$(CurrentSelection)" $(FileNameExt) | |
| command.261.*=dostring \ | |
| local function command_output(cmd) \ | |
| local tempfile = os.getenv('TMP') .. '\\scite_temp1' \ | |
| os.execute(cmd .. ' > ' .. tempfile) \ | |
| local h = io.open(tempfile) \ | |
| result = '' \ | |
| if h then \ | |
| result = h:read('*a') \ | |
| h:close() \ | |
| end \ | |
| return result \ | |
| end \ | |
| props['1']=(props['CurrentSelection']=='' and props['CurrentWord'] or props['CurrentSelection']) \ | |
| FIXME = "props['2']= '*.' .. props['FileExt'] -- no os.setcwd(?) in lua/scite?" \ | |
| props['2']=props['FileDir'] .. '\\*.' .. props['FileExt'] \ | |
| if scite.ShowParametersDialog('grep -nH $1 $2') then \ | |
| cmd = 'grep -nH \"' .. props['1'] .. '\" ' .. props['2'] \ | |
| print('> ' .. cmd) \ | |
| print(command_output(cmd)) \ | |
| end | |
| command.shortcut.261.*=Alt+G | |
| command.name.263.*=Ack in dir... | |
| command.mode.263.*=subsystem:lua,savebefore:no | |
| command.263.*=dostring \ | |
| local function command_output(cmd) \ | |
| local tempfile = os.getenv('TMP') .. '\\scite_temp1' \ | |
| os.execute(cmd .. ' > ' .. tempfile) \ | |
| local h = io.open(tempfile) \ | |
| result = '' \ | |
| if h then \ | |
| result = h:read('*a') \ | |
| h:close() \ | |
| end \ | |
| return result \ | |
| end \ | |
| props['1']=' -R -a --column ' \ | |
| props['2']=(props['CurrentSelection']=='' and props['CurrentWord'] or props['CurrentSelection']) \ | |
| props['3']=props['FileDir'] \ | |
| if scite.ShowParametersDialog('ack $1 "$2" "$3"') then \ | |
| cmd = string.format('ack %s "%s" "%s"', props['1'], props['2'], props['3']) \ | |
| print('> ' .. cmd) \ | |
| print(command_output(cmd)) \ | |
| end | |
| command.shortcut.263.*=Alt+A | |
| IDU_ACK_IN_FOLDERS=9263 | |
| command.name.264.*=Grin in dir... | |
| command.mode.264.*=subsystem:lua,savebefore:no | |
| command.264.*=dostring \ | |
| local function command_output(cmd) \ | |
| local tempfile = os.getenv('TMP') .. '\\scite_temp1' \ | |
| os.execute(cmd .. ' > ' .. tempfile) \ | |
| local h = io.open(tempfile) \ | |
| result = '' \ | |
| if h then \ | |
| result = h:read('*a') \ | |
| h:close() \ | |
| end \ | |
| return result \ | |
| end \ | |
| props['1']=' --emacs ' \ | |
| props['2']=(props['CurrentSelection']=='' and props['CurrentWord'] or props['CurrentSelection']) \ | |
| props['3']=props['FileDir'] \ | |
| if scite.ShowParametersDialog('grin $1 "$2" "$3"') then \ | |
| cmd = string.format('grin %s "%s" "%s"', props['1'], props['2'], props['3']) \ | |
| print('> ' .. cmd) \ | |
| print(command_output(cmd)) \ | |
| end | |
| command.shortcut.264.*=Ctrl+Shift+G | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment