{"id":513,"date":"2007-04-30T09:25:43","date_gmt":"2007-04-30T16:25:43","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/2007\/04\/30\/bash-alias-svn_diff_counter-count-lines-added-and-removed\/"},"modified":"2007-04-30T09:25:43","modified_gmt":"2007-04-30T16:25:43","slug":"bash-alias-svn_diff_counter-count-lines-added-and-removed","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/bash-alias-svn_diff_counter-count-lines-added-and-removed\/","title":{"rendered":"Bash Alias &#8211; &#8220;svn_diff_counter&#8221;: Count lines added and removed"},"content":{"rendered":"<p>I love to know how many lines I&#8217;ve added and deleted before making a commit.<\/p>\n<p>This is why I created this alias:<\/p>\n<p><code style=\"color:#0A0; font-weight:bolder; font-family:Courier\"><br \/>\nalias svn_diff_counter='svn diff | egrep \"^[+|-].*\" | egrep -v \"(+++)|(---)\" > .tmp_diff_counter ; added=`egrep \"(^+)\" .tmp_diff_counter | wc -l`; removed=`egrep \"(^-)\" .tmp_diff_counter | wc -l`; rm .tmp_diff_counter; echo \"Lines Added vs. Line Removed since your last commit\"; echo \"+ ${added}\"; echo \"- ${removed}\"; echo;'<\/code><br \/>\n(actualizado el 3 de mayo de 2003 a las 4:03pm, NT Time)<\/p>\n<p><em>En Espa&ntilde;ol<\/em><br \/>\nColoca este alias en tu .bash_profile o .bashrc (o .bash_aliases, si tienes un script como yo con puros aliases invocado por .bashrc \ud83d\ude42 ). Si estas trabajando con un repositorio SVN a veces es divertido ver cuantas lineas de codigo agregaste y cuantas lineas de codigo borraste desde tu ultimo commit. Solo ejecutas este alias &#8220;svn_diff_counter&#8221; y tendras el numero de lineas cambiadas dentro de todos los subdirectorios desde donde estas parado.<\/p>\n<p>Si ves el alias en detalle es muy sencillo, Hago diff, luego extraigo con un regexp todas las lineas que comienzan por &#8220;+&#8221; y por &#8220;-&#8220;, y pongo eso en un archivo temporal, luego vuelvo a hacer un grep para las que comienzan con &#8220;+&#8221; y cuento cuantas lineas hay despues del grep, y meto eso en una variable, repito lo mismo para &#8220;-&#8220;, elimino el archivo temporal y luego imprimo los resultados.<\/p>\n<p>Una vez puesto el alias, solo escribes &#8220;svn_&#8221; [Tab][Enter] y listo<br \/>\n(si no tienes otro alias\/comando que comienze por &#8220;svn_&#8221;)<\/p>\n<p>Enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I love to know how many lines I&#8217;ve added and deleted before making a commit. This is why I created this alias: alias svn_diff_counter=&#8217;svn diff | egrep &#8220;^[+|-].*&#8221; | egrep -v &#8220;(+++)|(&#8212;)&#8221; > .tmp_diff_counter ; added=`egrep &#8220;(^+)&#8221; .tmp_diff_counter | wc -l`; removed=`egrep &#8220;(^-)&#8221; .tmp_diff_counter | wc -l`; rm .tmp_diff_counter; echo &#8220;Lines Added vs. Line Removed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15,30,43],"tags":[],"class_list":["post-513","post","type-post","status-publish","format-standard","hentry","category-code","category-geeklife","category-linux"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-8h","jetpack-related-posts":[{"id":360,"url":"https:\/\/www.gubatron.com\/blog\/como-matar-varios-procesos-cuando-killall-no-es-una-opcion\/","url_meta":{"origin":513,"position":0},"title":"Como matar varios procesos cuando killall no es una opcion.","author":"gubatron","date":"August 15, 2006","format":false,"excerpt":"A veces tienes un cronjob que se queda pegado por mucho rato, cuando haces Code: ps aux | grep miPrograma tienes un monton de instancias pegadas!! Intentas hacer killall miPrograma pero no funciona porque quizas es un programa que estas arrancando con un interprete, como python, o php, o perl.\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":570,"url":"https:\/\/www.gubatron.com\/blog\/check-if-your-phps-diff-syntax-isnt-breaking\/","url_meta":{"origin":513,"position":1},"title":"Check if your PHP&#8217;s diff syntax isn&#8217;t breaking","author":"gubatron","date":"August 11, 2007","format":false,"excerpt":"Say you're working on emacs, without any kind of syntax checking, and you don't want to commit your code cause you might have syntax errors. If you're smart, the best way to know what files you actually changed, is using svn diff | grep +++ (that is, if you're using\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2087,"url":"https:\/\/www.gubatron.com\/blog\/mercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads\/","url_meta":{"origin":513,"position":2},"title":"Mercurial for Subversion Expats: Merging remote changes. &#8220;abort: push creates new remote heads!&#8221;","author":"gubatron","date":"November 14, 2010","format":false,"excerpt":"Commit anywhere\/anytime with Mercurial So you have been using subversion for the past few years and now your team has decided to move on to Mercurial for all the benefits. Two or more people are working on the same branch and they're pushing code to the main copy of the\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":330,"url":"https:\/\/www.gubatron.com\/blog\/trac-svn-the-best-shit-ever-for-your-software-project\/","url_meta":{"origin":513,"position":3},"title":"Trac + SVN : The best shit ever for your software project","author":"gubatron","date":"June 21, 2006","format":false,"excerpt":"The company I came to work for knew I had some experience with subversion (back at LimeWire and with the migration of Frostwire's CVS Repo no SourceForge.net to Subversion) so that's one of the first things I did here. Subversion is a pretty useful tool, specially if you play with\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2722,"url":"https:\/\/www.gubatron.com\/blog\/add-ssh-identities-to-your-ssh-agent-when-you-start-your-bash-session\/","url_meta":{"origin":513,"position":4},"title":"add ssh identities to your ssh agent when you start your bash session","author":"gubatron","date":"April 28, 2012","format":false,"excerpt":"Put this somewhere on your .bash_profile [bash] function addSSHIdentities() { pushd ~\/.ssh #add all your keys here ssh-add some_private_key ssh-add some_private_key_2 ssh-add some_private_key_3 ... ssh-add some_private_key_N popd } function startSSHAgent() { SSH_AGENT_PROCESSES=`ps aux | grep ssh-agent | grep -v grep | wc -l` if [ $SSH_AGENT_PROCESSES -gt 0 ] then\u2026","rel":"","context":"In \"posix\"","block_context":{"text":"posix","link":"https:\/\/www.gubatron.com\/blog\/tag\/posix\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":593,"url":"https:\/\/www.gubatron.com\/blog\/ssh-add-l-cannot-connect-to-your-agent\/","url_meta":{"origin":513,"position":5},"title":"ssh-add -l -> Cannot connect to your agent.","author":"gubatron","date":"September 21, 2007","format":false,"excerpt":"keychain not working for ya... you run ssh-agent but ssh-add won't add the keys. This is probably because your SSH_AGENT_PID and SSH_AUTH_SOCK variables are incorrect... so I recommend you put something like this on your .bashrc to initialize your ssh-agent correctly: export SSH_AGENT_PID= export SSH_AUTH_SOCK= #make sure no old agents\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=513"}],"version-history":[{"count":0,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/513\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}