org-bash-utils icon indicating copy to clipboard operation
org-bash-utils copied to clipboard

Utils BASH scripts for org-mode

#+TITLE: Org Bash Utils #+AUTHOR: Osiris Alejandro Gómez #+EMAIL: [email protected] #+LANGUAGE: es #+LINK_HOME: index.html #+LINK: ISSUE https://github.com/osiris/org-bash-utils/issues/ #+INCLUDE: "obu.org"

** overview

Repository of bash scripts for parse org-mode files.

** install

Clone the repository:

#+BEGIN_SRC sh :session :results none :exports code cd ~ git clone https://github.com/osiris/org-bash-utils #+END_SRC

Add to =~/.bashrc=:

#+BEGIN_SRC sh :session :results none :exports code if [ -d "$HOME/org-bash-utils" ] then PATH="$HOME/org-bash-utils:$PATH" source $HOME/org-bash-utils/org-alias source $HOME/org-bash-utils/awk-alias fi #+END_SRC

** scripts *** =agenda-ascii=

Exports =.org= file to a calendar =.ics=, after convert to /Remind
file/ =.rem= for finally draw a calendar ASCII:

#+BEGIN_SRC sh :session :results output :exports both
  agenda-ascii -f obu -r3 -c 80
#+END_SRC

#+RESULTS:
#+begin_example
CONVERT ICS TO REM ...
+----------+----------+----------+----------+----------+----------+----------+
|  Sunday  |  Monday  | Tuesday  |Wednesday | Thursday |  Friday  | Saturday |
+----------+----------+----------+----------+----------+----------+----------+
|9 Mar     |10 Mar    |11 Mar ***|12 Mar    |13 Mar    |14 Mar    |15 Mar    |
|          |          |          |          |          |          |          |
|          |NEXT      |          |          |          |          |          |
|          |Release   |          |          |          |          |          |
|          |0.1       |          |          |          |          |          |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
+----------+----------+----------+----------+----------+----------+----------+
|16 Mar    |17 Mar    |18 Mar    |19 Mar    |20 Mar    |21 Mar    |22 Mar    |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
+----------+----------+----------+----------+----------+----------+----------+
|23 Mar    |24 Mar    |25 Mar    |26 Mar    |27 Mar    |28 Mar    |29 Mar    |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
|          |          |          |          |          |          |          |
+----------+----------+----------+----------+----------+----------+----------+
#+end_example

*** =barra=

This script draw a simple bar chart. The input is a column number and a column text like this:

#+BEGIN_SRC sh :session :results output :exports both
  org-status | head
#+END_SRC

#+RESULTS:
#+begin_example
   3224 DONE
    377 NEXT
    132 CANCELLED
    117 TODO
     45 FIXED
      8 SOMEDAY
      8 DELEGATED
      6 TODAY
      5 WAITING
      5 POSTPONED
#+end_example

After you add a =pipe= and =barra= the result is:

#+BEGIN_SRC sh :session :results output :exports both
  org-status | head | barra
#+END_SRC

#+RESULTS:
#+begin_example
 82.10 %  82.10 %      3224 █████████████████████████████████████████ DONE
 91.70 %   9.60 %       377 █████ NEXT
 95.06 %   3.36 %       132 █ CANCELLED
 98.04 %   2.98 %       117 █ TODO
 99.19 %   1.15 %        45 ▌ FIXED
 99.39 %   0.20 %         8 ▌ SOMEDAY
 99.59 %   0.20 %         8 ▌ DELEGATED
 99.75 %   0.15 %         6 ▌ TODAY
 99.87 %   0.13 %         5 ▌ WAITING
100.00 %   0.13 %         5 ▌ POSTPONED
                       3927
#+end_example

If you configure =HISTTIMEFORMAT="%Y-%m-%d %H:%M "= into
=~/.bashrc=, you can obtain a statistics of =bash= use:

#+BEGIN_EXAMPLE
  history | grep 2014-04-11 | awk '{print $4}' | sort | uniq -c | sort -nr | head | barra
#+END_EXAMPLE

#+BEGIN_EXAMPLE
   23.57 %  23.57 %        37 ████████████ :q
   41.40 %  17.83 %        28 █████████ v
   54.78 %  13.38 %        21 ██████ cd
   66.24 %  11.46 %        18 █████ e
   75.16 %   8.92 %        14 ████ ls
   83.44 %   8.28 %        13 ████ ssh
   87.90 %   4.46 %         7 ██ ./ssltest.py
   92.36 %   4.46 %         7 ██ cdv
   96.18 %   3.82 %         6 ██ exit
  100.00 %   3.82 %         6 ██ echo
                          157
#+END_EXAMPLE

*** =org-clock=

Show a =CLOCK:= lines in all =.org= files for specific date:

#+BEGIN_SRC sh :session :results output
  org-clock 2014-02-28
#+END_SRC

#+RESULTS:
: 13:09 13:40 almuerzo
: 12:26 13:05 gca
: 13:40 15:56 gca
: 13:40 15:56 gca
: 16:18 17:03 gca
: 20:28 20:38 gca
: 20:39 20:44 gca
: 21:08 21:38 gca

Default is current day:

#+BEGIN_SRC sh :session :results output :exports both
  org-clock
#+END_SRC

#+RESULTS:
: 13:49 14:48 almuerzo
: 09:36 10:04 auditoria
: 12:55 13:05 auditoria
: 13:22 13:47 auditoria
: 10:12 10:29 gastos
: 10:30 10:40 gastos
: 10:50 12:20 marian
: 08:32 09:00 org

You can view a specific file:

#+BEGIN_SRC sh :session :results output :exports both
  org-clock 2014-02 almuerzo.org
#+END_SRC

#+RESULTS:
#+begin_example
13:50 14:28 2014-02-04
14:37 15:17 2014-02-06
14:14 15:20 2014-02-07
13:50 14:38 2014-02-10
13:55 14:48 2014-02-13
13:42 14:42 2014-02-14
11:50 14:50 2014-02-17
13:40 15:04 2014-02-18
13:37 13:48 2014-02-20
14:02 15:00 2014-02-20
14:00 14:49 2014-02-24
14:00 15:00 2014-02-25
13:09 13:40 2014-02-28
#+end_example

Adding =org-timeline= to result:

#+BEGIN_SRC sh :session :results output :exports both
  org-clock 2014-02 almuerzo.org | org-timeline
#+END_SRC

#+RESULTS:
#+begin_example
11:    12:    13:    14:    15:    16:
  ┊      ┊      ┊      ┊      ┊      ┊
  ┊□□□□▣▣┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊ 2014-02-17 ===============>  180
  ┊□□□□□□┊□□□□□□┊□□□▣▣▣┊□□□□□□┊□□□□□□┊ 2014-02-18 ===============>   84
  ┊□□□□□□┊□□□□□□┊□▣▣▣□□┊□□□□□□┊□□□□□□┊ 2014-02-28 ===============>   31
  ┊□□□□□□┊□□□□□□┊□□□□▣▣┊□□□□□□┊□□□□□□┊ 2014-02-10 ===============>   48
  ┊□□□□□□┊□□□□□□┊□□□▣▣□┊▣▣▣▣▣▣┊□□□□□□┊ 2014-02-20 ===============>   69
  ┊□□□□□□┊□□□□□□┊□□□□□▨┊□□□□□□┊□□□□□□┊ 2014-02-13 ===============>   53
  ┊□□□□□□┊□□□□□□┊□□□□▣▣┊□□□□□□┊□□□□□□┊ 2014-02-04 ===============>   38
  ┊□□□□□□┊□□□□□□┊□□□▣▣▣┊□□□□□□┊□□□□□□┊ 2014-02-14 ===============>   60
  ┊□□□□□□┊□□□□□□┊□□□□□□┊▣▣▣▣▣□┊□□□□□□┊ 2014-02-24 ===============>   49
  ┊□□□□□□┊□□□□□□┊□□□□□□┊□□□▣▣▣┊□□□□□□┊ 2014-02-06 ===============>   40
  ┊□□□□□□┊□□□□□□┊□□□□□□┊▣▣▣▣▣▣┊□□□□□□┊ 2014-02-25 ===============>   60
  ┊□□□□□□┊□□□□□□┊□□□□□□┊□▨▣▣▣▣┊□□□□□□┊ 2014-02-07 ===============>   66
  ┊      ┊      ┊      ┊      ┊      ┊      TOTAL ===============>  778
#+end_example

*** =org-count=

By default count tasks with =NEXT= keyword:

#+BEGIN_SRC sh :session :results output :exports both
  org-count | head
#+END_SRC

#+RESULTS:
#+begin_example
    159 gca
     26 gcoop
     20 org
     20 cfp
     18 leonel
     16 osiux
     14 plan
     12 gastos
     11 frontweb
     10 osiris
#+end_example

Count specific =TODO KEYWORD=:

#+BEGIN_SRC sh :session :results output :exports both
  org-count TODO | head
#+END_SRC

#+RESULTS:
#+begin_example
     32 org
     13 caipiroska
     11 auditoria
     10 gcoop
     10 bal
     10 arbolito
      6 osiris
      6 frontweb
      4 SLconCFK
      4 osiux
#+end_example

*** =org-status=

Show status of =TODO KEYWORDS= for =*.org= files:

#+BEGIN_SRC sh :session :results output :exports both
  org-status | head | barra
#+END_SRC

#+RESULTS:
#+begin_example
 81.94 %  81.94 %      3245 █████████████████████████████████████████ DONE
 91.72 %   9.77 %       387 █████ NEXT
 95.05 %   3.33 %       132 █ CANCELLED
 98.06 %   3.01 %       119 █ TODO
 99.19 %   1.14 %        45 ▌ FIXED
 99.39 %   0.20 %         8 ▌ SOMEDAY
 99.60 %   0.20 %         8 ▌ DELEGATED
 99.75 %   0.15 %         6 ▌ TODAY
 99.87 %   0.13 %         5 ▌ WAITING
100.00 %   0.13 %         5 ▌ POSTPONED
                       3960
#+end_example

Show status of =TODO KEYWORDS= for =obu.org= file:

#+BEGIN_SRC sh :session :results output :exports both
  org-status obu.org | barra
#+END_SRC

#+RESULTS:
:  55.56 %  55.56 %         5 ████████████████████████████ NEXT
:  88.89 %  33.33 %         3 ████████████████ DONE
: 100.00 %  11.11 %         1 █████ TODO
:                           9

*** =org-timeline=

Draw a timeline for a serie of start and end date, group by third column:

#+BEGIN_SRC sh :session :results output :exports both
  org-clock 2014-02-28 | org-timeline
#+END_SRC

#+RESULTS:
: 12:    13:    14:    15:    16:    17:    18:    19:    20:    21:    22:
:   ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊
:   ┊□□□□□□┊□▣▣▣□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊   almuerzo ===============>   31
:   ┊□□▨▣▣▣┊□□□▣▣▣┊□□□□□□┊□□□□□□┊□▣▣▣▣▣┊□□□□□□┊□□□□□□┊□□□□□□┊□□▣▣▨□┊□▣▣▣□□┊        gca ===============>  401
:   ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      TOTAL ===============>  432


View detail of each line before group with =-d=2= parameter:

#+BEGIN_SRC sh :session :results output :exports both
  org-clock 2014-02-28 | org-timeline -v d=2
#+END_SRC

#+RESULTS:
#+begin_example
12:    13:    14:    15:    16:    17:    18:    19:    20:    21:    22:
  ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊
  ┊□□□□□□┊□▣▣▣□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊   almuerzo 13:09 - 13:40 =>   31
  ┊□□□□□□┊□▣▣▣□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊   almuerzo ===============>   31
  ┊□□▨▣▣▣┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊        gca 12:26 - 13:05 =>   39
  ┊□□□□□□┊□□□▣▣▣┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊        gca 13:40 - 15:56 =>  136
  ┊□□□□□□┊□□□▣▣▣┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊        gca 13:40 - 15:56 =>  136
  ┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□▣▣▣▣▣┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊        gca 16:18 - 17:03 =>   45
  ┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□▣▣□□┊□□□□□□┊        gca 20:28 - 20:38 =>   10
  ┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□▣▨□┊□□□□□□┊        gca 20:39 - 20:44 =>    5
  ┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□□□□□□┊□▣▣▣□□┊        gca 21:08 - 21:38 =>   30
  ┊□□▨▣▣▣┊□□□▣▣▣┊□□□□□□┊□□□□□□┊□▣▣▣▣▣┊□□□□□□┊□□□□□□┊□□□□□□┊□□▣▣▨□┊□▣▣▣□□┊        gca ===============>  401
  ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      ┊      TOTAL ===============>  432
#+end_example