Here is an macro that stops with a pop-up message. It greps given string from files in current directory and allows user to open a file from the line containing the string.
if ($selection_start > -1) {
string = get_selection()
} else {
string = string_dialog("Give string to grep")
}
matches = shell_command("grep -ni '" string "' * |& grep -v '^grep: '", "")
if ( matches == "" ) {
dialog("No matches found for " string)
}
selection = 1
while ( selection != "" && matches != "" ) {
selection = list_dialog( "Select one of the matching lines___________________________________________________________________________________________________________________________________________________________________________________________________________", matches )
if ( selection != "" ) {
file = selection
file = replace_in_string(file, ":.*", "", "regex")
line = selection
line = replace_in_string(line, ":\\D.*", "", "regex")
line = replace_in_string(line, ".*:", "", "regex")
if ( ( file == "") || ( line == "" ) ) {
dialog("Something wrong with this macro: " selection "--" file "__" line, "OK")
} else {
open($file_path file)
focus_window($file_path file)
goto_line_number(line)
}
}
matches = shell_command("grep -ni '" string "' * |& grep -v '^grep: '", "")
}
Here is an macro that stops with a pop-up message. It greps given string from files in current directory and allows user to open a file from the line containing the string.