README.rst 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. howdoi
  2. ====================================================
  3. .. image:: http://imgs.xkcd.com/comics/tar.png
  4. :target: https://xkcd.com/1168/
  5. instant coding answers via the command line
  6. -------------------------------------------
  7. .. image:: https://secure.travis-ci.org/gleitz/howdoi.png?branch=master
  8. :target: https://travis-ci.org/gleitz/howdoi
  9. Are you a hack programmer? Do you find yourself constantly Googling for
  10. how to do basic programming tasks?
  11. Suppose you want to know how to format a date in bash. Why open your browser
  12. and read through blogs (risking major distraction) when you can simply stay
  13. in the console and ask howdoi:
  14. ::
  15. $ howdoi format date bash
  16. > DATE=`date +%Y-%m-%d`
  17. howdoi will answer all sorts of queries:
  18. ::
  19. $ howdoi print stack trace python
  20. > import traceback
  21. >
  22. > try:
  23. > 1/0
  24. > except:
  25. > print '>>> traceback <<<'
  26. > traceback.print_exc()
  27. > print '>>> end of traceback <<<'
  28. > traceback.print_exc()
  29. $ howdoi convert mp4 to animated gif
  30. > video=/path/to/video.avi
  31. > outdir=/path/to/output.gif
  32. > mplayer "$video" \
  33. > -ao null \
  34. > -ss "00:01:00" \ # starting point
  35. > -endpos 10 \ # duration in second
  36. > -vo gif89a:fps=13:output=$outdir \
  37. > -vf scale=240:180
  38. $ howdoi create tar archive
  39. > tar -cf backup.tar --exclude "www/subf3" www
  40. Installation
  41. ------------
  42. ::
  43. pip install howdoi
  44. or
  45. ::
  46. pip install git+https://github.com/gleitz/howdoi.git#egg=howdoi
  47. or
  48. ::
  49. brew install https://raw.github.com/gleitz/howdoi/master/howdoi.rb
  50. or
  51. ::
  52. python setup.py install
  53. Usage
  54. -----
  55. ::
  56. usage: howdoi.py [-h] [-p POS] [-a] [-l] [-c] [-n NUM_ANSWERS] [-C] [-v] QUERY [QUERY ...]
  57. instant coding answers via the command line
  58. positional arguments:
  59. QUERY the question to answer
  60. optional arguments:
  61. -h, --help show this help message and exit
  62. -p POS, --pos POS select answer in specified position (default: 1)
  63. -a, --all display the full text of the answer
  64. -l, --link display only the answer link
  65. -c, --color enable colorized output
  66. -n NUM_ANSWERS, --num-answers NUM_ANSWERS
  67. number of answers to return
  68. -C, --clear-cache clear the cache
  69. -v, --version displays the current version of howdoi
  70. As a shortcut, if you commonly use the same parameters each time and don't want to type them, add something similar to your .bash_profile (or otherwise). This example gives you 5 colored results each time.
  71. ::
  72. alias h='function hdi(){ howdoi $* -c -n 5; }; hdi'
  73. And then to run it from the command line simply type:
  74. ::
  75. $h this is my query for howdoi
  76. Author
  77. ------
  78. - Benjamin Gleitzman (`@gleitz <http://twitter.com/gleitz>`_)
  79. Notes
  80. -----
  81. - Works with Python2 and Python3
  82. - A standalone Windows executable with the howdoi application `is available here <https://dl.dropbox.com/u/101688/website/misc/howdoi.exe>`_.
  83. - An Alfred Workflow for howdoi can be found at `http://blog.gleitzman.com/post/48539944559/howdoi-alfred-even-more-instant-answers <http://blog.gleitzman.com/post/48539944559/howdoi-alfred-even-more-instant-answers>`_.
  84. - Slack integration available through `slack-howdoi <https://github.com/ellisonleao/slack-howdoi>`_.
  85. - Howdoi uses a cache for faster access to previous questions. Caching functionality can be disabled by setting the HOWDOI_DISABLE_CACHE environment variable. The cache is stored in `~/.cache/howdoi`.
  86. - You can set the HOWDOI_URL environment variable to change the source url for answers (default: `stackoverflow.com`, also supported: `serverfault.com`, `pt.stackoverflow.com`, `full list <http://stackexchange.com/sites?view=list#traffic>`_).
  87. - You can set the HOWDOI_SEARCH_ENGINE environment variable to change the underlying search engine for StackOverflow links (default: `google`, also supported: `bing`).
  88. - Setting the HOWDOI_COLORIZE environment variable will colorize the output by default.
  89. - Special thanks to Rich Jones (`@miserlou <https://github.com/miserlou>`_) for the idea.
  90. Development
  91. -----------
  92. - Checkout the repo
  93. - Run ``python -m howdoi.howdoi QUERY`` (if you try running ``python howdoi/howdoi.py`` you might get ``ValueError: Attempted relative import in non-package``).
  94. Troubleshooting
  95. ---------------
  96. You might get the following error when installing with Homebrew:
  97. ::
  98. ==> python setup.py install
  99. http://peak.telecommunity.com/EasyInstall.html
  100. Please make the appropriate changes for your system and try again.
  101. Fix the error by executing the following command:
  102. ::
  103. sudo chmod -R go+w /Library/Python/2.7/site-packages/
  104. An official lxml for python 3.3+ for windows has not yet been released. You may get an error while installing.
  105. Try and install an unofficial binary for lxml from
  106. ::
  107. http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml