diff options
author | Anastasis Grammenos <anastasis.gramm2@gmail.com> | 2018-09-28 23:23:08 +0300 |
---|---|---|
committer | Anastasis Grammenos <anastasis.gramm2@gmail.com> | 2018-09-28 23:23:08 +0300 |
commit | 6d162956409c0fa394920ba707109afdbff041e5 (patch) | |
tree | e8ba35a7bc0c4ddc2e18b0ad637f440f0ce4f16a | |
parent | 0537597c4924e48b18ca79005be2103079b8d009 (diff) | |
download | ck-6d162956409c0fa394920ba707109afdbff041e5.tar.gz ck-6d162956409c0fa394920ba707109afdbff041e5.tar.bz2 ck-6d162956409c0fa394920ba707109afdbff041e5.zip |
fix minor grep nuiscance
-rw-r--r-- | README.html | 260 | ||||
-rw-r--r-- | README.org | 21 | ||||
-rw-r--r-- | src/actions.c | 6 |
3 files changed, 156 insertions, 131 deletions
diff --git a/README.html b/README.html index 7a0e391..a1f67cd 100644 --- a/README.html +++ b/README.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> -<!-- 2018-09-27 Thu 12:36 --> +<!-- 2018-09-28 Fri 23:23 --> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>‎</title> @@ -232,35 +232,35 @@ for the JavaScript code in this tag. <h2>Table of Contents</h2> <div id="text-table-of-contents"> <ul> -<li><a href="#org0436b21">ck</a></li> -<li><a href="#org521e187">build it</a> +<li><a href="#org1d54245">ck</a></li> +<li><a href="#org0f23886">build it</a> <ul> -<li><a href="#orgca52abe">requirements</a></li> -<li><a href="#org6b9a0b5">compiler</a></li> -<li><a href="#orgdbbfa92">make</a></li> +<li><a href="#org633fb0e">requirements</a></li> +<li><a href="#org132a993">compiler</a></li> +<li><a href="#orgad56911">make</a></li> </ul> </li> -<li><a href="#orgde3e768">for devs</a> +<li><a href="#orgb2415b8">for devs</a> <ul> -<li><a href="#orgfaa2574">CMake options</a></li> -<li><a href="#orgf23c175">tests</a> +<li><a href="#orgfebd554">CMake options</a></li> +<li><a href="#orgba141a7">tests</a> <ul> -<li><a href="#org3dfeb24">run tests</a></li> -<li><a href="#org9d9b2b2">test suite</a></li> +<li><a href="#orgbdc8dd5">run tests</a></li> +<li><a href="#orgc178ae2">test suite</a></li> </ul> </li> </ul> </li> -<li><a href="#org02afa67">manual</a> +<li><a href="#orgac988ad">manual</a> <ul> -<li><a href="#orga3cd4d1">ck configuration</a></li> -<li><a href="#orgacbdbc9">Actions</a> +<li><a href="#org17fe919">ck configuration</a></li> +<li><a href="#orgeb1a91b">Actions</a> <ul> -<li><a href="#org0e7f64a">init</a></li> -<li><a href="#orgb4b8714">add</a></li> -<li><a href="#org6456e5e">list</a></li> -<li><a href="#orgd015339">search</a></li> -<li><a href="#orgbbfaad1">edit</a></li> +<li><a href="#orga34159d">init</a></li> +<li><a href="#orgfcddcc0">add</a></li> +<li><a href="#orgb841b44">list</a></li> +<li><a href="#org1acb8b9">search</a></li> +<li><a href="#org511c981">edit</a></li> </ul> </li> </ul> @@ -269,22 +269,22 @@ for the JavaScript code in this tag. </div> </div> <p align="center"><img src="res/logo.png" width="30%" height="30%" /></p> -<div id="outline-container-org0436b21" class="outline-2"> -<h2 id="org0436b21">ck</h2> -<div class="outline-text-2" id="text-org0436b21"> +<div id="outline-container-org1d54245" class="outline-2"> +<h2 id="org1d54245">ck</h2> +<div class="outline-text-2" id="text-org1d54245"> <p> <b>The Config Keeper</b> </p> </div> </div> -<div id="outline-container-org521e187" class="outline-2"> -<h2 id="org521e187">build it</h2> -<div class="outline-text-2" id="text-org521e187"> +<div id="outline-container-org0f23886" class="outline-2"> +<h2 id="org0f23886">build it</h2> +<div class="outline-text-2" id="text-org0f23886"> </div> -<div id="outline-container-orgca52abe" class="outline-3"> -<h3 id="orgca52abe">requirements</h3> -<div class="outline-text-3" id="text-orgca52abe"> +<div id="outline-container-org633fb0e" class="outline-3"> +<h3 id="org633fb0e">requirements</h3> +<div class="outline-text-3" id="text-org633fb0e"> <ul class="org-ul"> <li>clang (llvm) or gcc (gnu)</li> <li>cmake</li> @@ -293,31 +293,31 @@ for the JavaScript code in this tag. </div> </div> -<div id="outline-container-org6b9a0b5" class="outline-3"> -<h3 id="org6b9a0b5">compiler</h3> -<div class="outline-text-3" id="text-org6b9a0b5"> +<div id="outline-container-org132a993" class="outline-3"> +<h3 id="org132a993">compiler</h3> +<div class="outline-text-3" id="text-org132a993"> <div class="org-src-container"> -<pre class="src src-sh">> export <span style="color: #baba36;">CC</span>=clang -<span style="color: #656565;"># </span><span style="color: #757575;">or</span> -> export <span style="color: #baba36;">CC</span>=gcc +<pre class="src src-sh">> export <span style="color: #ffac4a;">CC</span>=clang +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">or</span> +> export <span style="color: #ffac4a;">CC</span>=gcc </pre> </div> </div> </div> -<div id="outline-container-orgdbbfa92" class="outline-3"> -<h3 id="orgdbbfa92">make</h3> -<div class="outline-text-3" id="text-orgdbbfa92"> +<div id="outline-container-orgad56911" class="outline-3"> +<h3 id="orgad56911">make</h3> +<div class="outline-text-3" id="text-orgad56911"> <div class="org-src-container"> -<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">clone the repo</span> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">clone the repo</span> > cd ~/code; git clone https://gitlab.com/grm-grm/ck -<span style="color: #656565;"># </span><span style="color: #757575;">make a build directory and enter it</span> -> mkdir ~/ck_build; <span style="color: #528fd1;">cd</span> ~/ck_build; -<span style="color: #656565;"># </span><span style="color: #757575;">run cmake</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">make a build directory and enter it</span> +> mkdir ~/ck_build; <span style="color: #ff0066;">cd</span> ~/ck_build; +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run cmake</span> > cmake ~/code/ck -<span style="color: #656565;"># </span><span style="color: #757575;">run make</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run make</span> > make -<span style="color: #656565;"># </span><span style="color: #757575;">run ck</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run ck</span> > ./ck </pre> </div> @@ -325,21 +325,21 @@ for the JavaScript code in this tag. </div> </div> -<div id="outline-container-orgde3e768" class="outline-2"> -<h2 id="orgde3e768">for devs</h2> -<div class="outline-text-2" id="text-orgde3e768"> +<div id="outline-container-orgb2415b8" class="outline-2"> +<h2 id="orgb2415b8">for devs</h2> +<div class="outline-text-2" id="text-orgb2415b8"> </div> -<div id="outline-container-orgfaa2574" class="outline-3"> -<h3 id="orgfaa2574">CMake options</h3> -<div class="outline-text-3" id="text-orgfaa2574"> +<div id="outline-container-orgfebd554" class="outline-3"> +<h3 id="orgfebd554">CMake options</h3> +<div class="outline-text-3" id="text-orgfebd554"> <p> cmake accepts the following options: </p> <div class="org-src-container"> -<pre class="src src-cmake"><span style="color: #6aaf50;">option</span>(CK_ASAN <span style="color: #bdbc61;">"Build with asan"</span>) -<span style="color: #6aaf50;">option</span>(CK_DEBUG <span style="color: #bdbc61;">"Build with debug symbols"</span>) -<span style="color: #6aaf50;">option</span>(CK_TESTS <span style="color: #bdbc61;">"Make the tests"</span>) -<span style="color: #6aaf50;">option</span>(CK_SHARED <span style="color: #bdbc61;">"Build with shared lib"</span>) +<pre class="src src-cmake"><span style="color: #63de5d;">option</span>(CK_ASAN <span style="color: #E6DB74;">"Build with asan"</span>) +<span style="color: #63de5d;">option</span>(CK_DEBUG <span style="color: #E6DB74;">"Build with debug symbols"</span>) +<span style="color: #63de5d;">option</span>(CK_TESTS <span style="color: #E6DB74;">"Make the tests"</span>) +<span style="color: #63de5d;">option</span>(CK_SHARED <span style="color: #E6DB74;">"Build with shared lib"</span>) </pre> </div> @@ -356,24 +356,24 @@ Just build with address sanitizer enabled like so: llvm has better asan than gcc, so I use that. </p> <div class="org-src-container"> -<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">clone the repo</span> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">clone the repo</span> > cd ~/code; git clone https://gitlab.com/grm-grm/ck -<span style="color: #656565;"># </span><span style="color: #757575;">make a build directory and enter it</span> -> mkdir ~/ck_build; <span style="color: #528fd1;">cd</span> ~/ck_build; -<span style="color: #656565;"># </span><span style="color: #757575;">run cmake</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">make a build directory and enter it</span> +> mkdir ~/ck_build; <span style="color: #ff0066;">cd</span> ~/ck_build; +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run cmake</span> > cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck -<span style="color: #656565;"># </span><span style="color: #757575;">run make</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run make</span> > make -<span style="color: #656565;"># </span><span style="color: #757575;">run ck</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run ck</span> > ./ck </pre> </div> </div> </div> -<div id="outline-container-orgf23c175" class="outline-3"> -<h3 id="orgf23c175">tests</h3> -<div class="outline-text-3" id="text-orgf23c175"> +<div id="outline-container-orgba141a7" class="outline-3"> +<h3 id="orgba141a7">tests</h3> +<div class="outline-text-3" id="text-orgba141a7"> <p> The testing "suite" is a bash script that runs regression and unit tests. Regression tests are under the <code>tests/</code> directory @@ -382,9 +382,9 @@ under <code>unit/</code> directory and test the code. </p> </div> -<div id="outline-container-org3dfeb24" class="outline-4"> -<h4 id="org3dfeb24">run tests</h4> -<div class="outline-text-4" id="text-org3dfeb24"> +<div id="outline-container-orgbdc8dd5" class="outline-4"> +<h4 id="orgbdc8dd5">run tests</h4> +<div class="outline-text-4" id="text-orgbdc8dd5"> <p> Simply go to the build dir and type. </p> @@ -395,9 +395,9 @@ Simply go to the build dir and type. </div> </div> -<div id="outline-container-org9d9b2b2" class="outline-4"> -<h4 id="org9d9b2b2">test suite</h4> -<div class="outline-text-4" id="text-org9d9b2b2"> +<div id="outline-container-orgc178ae2" class="outline-4"> +<h4 id="orgc178ae2">test suite</h4> +<div class="outline-text-4" id="text-orgc178ae2"> <div class="org-src-container"> <pre class="src src-sh">$ ./check_ck -h ck test suite @@ -415,9 +415,9 @@ flags: </div> </div> </div> -<div id="outline-container-org02afa67" class="outline-2"> -<h2 id="org02afa67">manual</h2> -<div class="outline-text-2" id="text-org02afa67"> +<div id="outline-container-orgac988ad" class="outline-2"> +<h2 id="orgac988ad">manual</h2> +<div class="outline-text-2" id="text-orgac988ad"> <p> ck's goal is to assist with the configuration file management. To that end it tries to provides a cli interface that is pretty straight-forward @@ -428,30 +428,30 @@ and intuitive. Example usage: </p> <div class="org-src-container"> -<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">initialize new ck</span> -$ ck init /path_to/where_you_want/your_configs/to_be <span style="color: #bdbc61;">\</span> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">initialize new ck</span> +$ ck init /path_to/where_you_want/your_configs/to_be <span style="color: #E6DB74; font-weight: bold;">\</span> /path_to/the_secret/directory -<span style="color: #656565;"># </span><span style="color: #757575;">add emacs configs</span> -<span style="color: #656565;">## </span><span style="color: #757575;">primary config</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">add emacs configs</span> +<span style="color: #6A6D70;">## </span><span style="color: #6A6D70;">primary config</span> $ ck add emacs ~/.emacs.d/orgconf.org -p -<span style="color: #656565;">## </span><span style="color: #757575;">secret config, with passwords and naughty words</span> +<span style="color: #6A6D70;">## </span><span style="color: #6A6D70;">secret config, with passwords and naughty words</span> $ ck add emacs ~/.emacs.d/accounts.org -s -<span style="color: #656565;">## </span><span style="color: #757575;">and another one for emacs</span> +<span style="color: #6A6D70;">## </span><span style="color: #6A6D70;">and another one for emacs</span> $ ck add emacs ~/.emacs.d/init.el -<span style="color: #656565;"># </span><span style="color: #757575;">add tmux config</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">add tmux config</span> $ ck add tmux ~/.tmux.conf -p -<span style="color: #656565;"># </span><span style="color: #757575;">list the configs</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">list the configs</span> $ ck list tree $ ck list paths -t lisp $ ck list programs -t python -<span style="color: #656565;"># </span><span style="color: #757575;">search the configs</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">search the configs</span> $ ck search search-term -$ ck search <span style="color: #bdbc61;">"\"search term with spaces\""</span> -$ ck search <span style="color: #bdbc61;">"\("</span> <span style="color: #656565;">#</span><span style="color: #757575;">escape symbols</span> +$ ck search <span style="color: #E6DB74;">"\"search term with spaces\""</span> +$ ck search <span style="color: #E6DB74;">"\("</span> <span style="color: #6A6D70;">#</span><span style="color: #6A6D70;">escape symbols</span> </pre> </div> @@ -467,9 +467,9 @@ of flags one has to pass to ck. </p> </div> -<div id="outline-container-orga3cd4d1" class="outline-3"> -<h3 id="orga3cd4d1">ck configuration</h3> -<div class="outline-text-3" id="text-orga3cd4d1"> +<div id="outline-container-org17fe919" class="outline-3"> +<h3 id="org17fe919">ck configuration</h3> +<div class="outline-text-3" id="text-org17fe919"> <p> ck uses sqlite to index the configuration files. The init action creates a <b>.ck</b> directory (under $HOME) @@ -497,13 +497,13 @@ directory of your choice. Usage: </p> <div class="org-src-container"> -<pre class="src src-sh">$ ck config ~/ ... <span style="color: #656565;"># </span><span style="color: #757575;">the default behaviour</span> +<pre class="src src-sh">$ ck config ~/ ... <span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">the default behaviour</span> -<span style="color: #656565;"># </span><span style="color: #757575;">/someplace/else must exist or</span> -<span style="color: #656565;"># </span><span style="color: #757575;">the action following it must be init</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">/someplace/else must exist or</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">the action following it must be init</span> $ ck conf /someplace/else ... -<span style="color: #656565;"># </span><span style="color: #757575;">same thing</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">same thing</span> $ ck c /someplace/else ... $ ck -c /someplace/else ... </pre> @@ -511,13 +511,13 @@ $ ck -c /someplace/else ... </div> </div> -<div id="outline-container-orgacbdbc9" class="outline-3"> -<h3 id="orgacbdbc9">Actions</h3> -<div class="outline-text-3" id="text-orgacbdbc9"> +<div id="outline-container-orgeb1a91b" class="outline-3"> +<h3 id="orgeb1a91b">Actions</h3> +<div class="outline-text-3" id="text-orgeb1a91b"> </div> -<div id="outline-container-org0e7f64a" class="outline-4"> -<h4 id="org0e7f64a">init</h4> -<div class="outline-text-4" id="text-org0e7f64a"> +<div id="outline-container-orga34159d" class="outline-4"> +<h4 id="orga34159d">init</h4> +<div class="outline-text-4" id="text-orga34159d"> <p> or i or -i </p> @@ -539,17 +539,17 @@ Use init to initialize a new ck database. Usage: </p> <div class="org-src-container"> -<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">initialize new ck</span> -$ ck init /path_to/where_you_want/your_configs/to_be <span style="color: #bdbc61;">\</span> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">initialize new ck</span> +$ ck init /path_to/where_you_want/your_configs/to_be <span style="color: #E6DB74; font-weight: bold;">\</span> /path_to/the_secret/directory </pre> </div> </div> </div> -<div id="outline-container-orgb4b8714" class="outline-4"> -<h4 id="orgb4b8714">add</h4> -<div class="outline-text-4" id="text-orgb4b8714"> +<div id="outline-container-orgfcddcc0" class="outline-4"> +<h4 id="orgfcddcc0">add</h4> +<div class="outline-text-4" id="text-orgfcddcc0"> <p> or a or -a </p> @@ -583,16 +583,16 @@ sure to use the same name.</li> Usage: </p> <div class="org-src-container"> -<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">add config to ck</span> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">add config to ck</span> $ ck add program_name config_path [-s] [-p] </pre> </div> </div> </div> -<div id="outline-container-org6456e5e" class="outline-4"> -<h4 id="org6456e5e">list</h4> -<div class="outline-text-4" id="text-org6456e5e"> +<div id="outline-container-orgb841b44" class="outline-4"> +<h4 id="orgb841b44">list</h4> +<div class="outline-text-4" id="text-orgb841b44"> <p> or ls or l or -l </p> @@ -625,20 +625,20 @@ It is best used with tree or plain paths. Usage: </p> <div class="org-src-container"> -<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">list tree structure, with attributes</span> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">list tree structure, with attributes</span> $ ck list tree -a -<span style="color: #656565;"># </span><span style="color: #757575;">list paths in python</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">list paths in python</span> $ ck l paths -t python -<span style="color: #656565;"># </span><span style="color: #757575;">list programs in lisp</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">list programs in lisp</span> $ ck ls programs -t lisp </pre> </div> </div> </div> -<div id="outline-container-orgd015339" class="outline-4"> -<h4 id="orgd015339">search</h4> -<div class="outline-text-4" id="text-orgd015339"> +<div id="outline-container-org1acb8b9" class="outline-4"> +<h4 id="org1acb8b9">search</h4> +<div class="outline-text-4" id="text-org1acb8b9"> <p> or s or -s </p> @@ -652,30 +652,44 @@ Takes one argument, the <b>search-term</b>. </p> <p> -To search for terms with spaces you have to put them in escaped quotes. -To search for special symbols you have to enclose them in quotes and escape them. +To search for terms with spaces you have to put them in quotes. </p> <p> Usage: </p> <div class="org-src-container"> -<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">search for parenthesis</span> -$ ck search <span style="color: #bdbc61;">"\("</span> -<span style="color: #656565;"># </span><span style="color: #757575;">search term with spaces</span> -$ ck search <span style="color: #bdbc61;">"\"This is a space\""</span> -<span style="color: #656565;"># </span><span style="color: #757575;">both</span> -$ ck search <span style="color: #bdbc61;">"\"(add 2 4)\""</span> -<span style="color: #656565;"># </span><span style="color: #757575;">and a normal one</span> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">search for parenthesis</span> +$ ck search <span style="color: #E6DB74;">\(</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">search term with spaces</span> +$ ck search <span style="color: #E6DB74;">"This is a space"</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">both</span> +$ ck search <span style="color: #E6DB74;">"(add 2 4)"</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">and a normal one</span> $ ck search alias </pre> </div> + +<p> +If you want to use more advanced grep techniques or even +a different pattern matching program you can do it like so: +</p> + +<div class="org-src-container"> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">with xargs</span> +$ ck ls paths | xargs grep -E <span style="color: #E6DB74;">'A|B'</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">or in bash</span> +$ for i<span style="color: #ff0066;"> in</span> $(ck ls paths); <span style="color: #ff0066;">do</span> grep -E <span style="color: #E6DB74;">'A|B'</span> $<span style="color: #ffac4a;">i</span>; <span style="color: #ff0066;">done</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">or in zsh</span> +$ for i ($(ck ls paths)) grep -E <span style="color: #E6DB74;">'A|B'</span> $<span style="color: #ffac4a;">i</span> +</pre> +</div> </div> </div> -<div id="outline-container-orgbbfaad1" class="outline-4"> -<h4 id="orgbbfaad1">edit</h4> -<div class="outline-text-4" id="text-orgbbfaad1"> +<div id="outline-container-org511c981" class="outline-4"> +<h4 id="org511c981">edit</h4> +<div class="outline-text-4" id="text-org511c981"> <p> or e or -e </p> @@ -701,7 +715,7 @@ To do it use: </div> </div> <div id="postamble" class="status"> -<p class="date">Created: 2018-09-27 Thu 12:36</p> +<p class="date">Created: 2018-09-28 Fri 23:23</p> <p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p> </div> </body> @@ -230,21 +230,32 @@ Perform infile grep in all the configurations ck keeps track of. Takes one argument, the *search-term*. -To search for terms with spaces you have to put them in escaped quotes. -To search for special symbols you have to enclose them in quotes and escape them. +To search for terms with spaces you have to put them in quotes. Usage: #+BEGIN_SRC sh # search for parenthesis - $ ck search "\(" + $ ck search \( # search term with spaces - $ ck search "\"This is a space\"" + $ ck search "This is a space" # both - $ ck search "\"(add 2 4)\"" + $ ck search "(add 2 4)" # and a normal one $ ck search alias #+END_SRC +If you want to use more advanced grep techniques or even +a different pattern matching program you can do it like so: + +#+BEGIN_SRC sh + # with xargs + $ ck ls paths | xargs grep -E 'A|B' + # or in bash + $ for i in $(ck ls paths); do grep -E 'A|B' $i; done + # or in zsh + $ for i ($(ck ls paths)) grep -E 'A|B' $i +#+END_SRC + *** edit or e or -e diff --git a/src/actions.c b/src/actions.c index 70705e4..e6eb3d3 100644 --- a/src/actions.c +++ b/src/actions.c @@ -213,10 +213,10 @@ int run_SEARCH(UserOpt *opt, Conf *conf) { if (list_size(paths)) { do { FILE *cmd; - char result[4096] = ""; - char command[STR_L] = "grep -H -n "; + char result[STR_L] = ""; + char command[STR_L] = "grep -H -n \""; strcat(command, list_get(opt->args)); - strcat(command, " "); + strcat(command, "\" "); strcat(command, list_get(paths)); cmd = popen(command, "r"); if (cmd == NULL) { |