Live data from Hacker News

Ask HN: What are your favorite terminal programs?

news.ycombinator.com

171–180 of 203 posts

Re: Ask HN: What are your favorite terminal programs?

#171

REQUEST: jq is great for json - but is there a "jq for xml"? Some webservices are still only available in xml (e.g. uv levels). I currently use XMLStarlet for xml in the terminal. There are extra annoyances in xml that you can't avoid (like namespaces), but it could be a lot closer to jq.

I’ve used https://github.com/ericchiang/xpup for this a few times.

Re: Ask HN: What are your favorite terminal programs?

#172
Some time ago I wrote just for fun this couple of lines:

> What else I'm missing out on

echo 'Currently there are ' $(ver=(/bin /sbin /usr/bin /usr/sbin) && ls ${ver[*]} | wc -l) 'commands installed and available in the system'

This prints the man page of 3 random commands. One by one. Is a way to discover a few new commands each day. To go to the next command and exit press q. I hope you enjoy it.

commandoftheday=(/bin /sbin /usr/bin /usr/sbin) && ls ${commandoftheday} |sort -R |head -3 |xargs man '{}'

Re: Ask HN: What are your favorite terminal programs?

#173

First of all, you might want to check out the subreddit: /r/commandline https://www.reddit.com/r/commandline/ general commands - awk/grep/sed/wc - text file processing - convert (image magick) - image processing tool - cpulimit - limit the cpu usage of a process - fdupes - check for duplicate files and optionally remove them - pdftk - concatenate pdf files and more - https://www.pdflabs.com/tools/pdftk-the-pdf-toolki…

fdupes is terrific, but I find that rdfind is an improved version. Can do useful things that fdupes can't.

Pdftk is a must. I use pdflatex also a lot of course. And R and psql.

Re: Ask HN: What are your favorite terminal programs?

#174

Earlier quoted context omitted.

The benefit of tmuxp is pretty clear from its README[1]. It gives this example: session_name: 4-pane-split windows: - window_name: dev window layout: tiled shell_command_before: - cd ~/ # run as a first command in all panes panes: - shell_command: # pane no. 1 - cd /var/log # run multiple commands in this pane - ls -al | grep \.log - echo second pane # pane no. 2 - echo third pane # pane no. 3 - echo forth pane # pan…

I use a shell script for such config. eg tmux split-window -h ; tmux send-keys "ls -la" C-m; ...

As I mentioned earlier, it is possible to do such things within the .tmux.conf, but not practical. Here's one of my real tmuxp configs:

    # How to use this file:
    #   tmuxp load /path/to/this/file/main.yaml
    # - Specifying the .yaml extension is optional
    # - Specifying the path is optional if file is in ~/.tmuxp
    #
    #   tmuxp --help for full help.
    session_name: main
    suppress_history: false
    start_directory: '~'
    shell_command_before:
      - unsetenv SHELL_CONFIG_LOADED
      - source ~/.alias
    windows:
      - window_name: '*scratch*'
        layout: tiled
        focus: true
        panes:
          - cd ~/downloads/git           # Top-left
          - cd ~/downloads/git/emacs     # Top-right
          - focus: true                  # Bottom-left
            shell_command:
              - bob
              - sleep 2
              - tclr                     # Clear tmux status indicators
          - shell_command:               # Bottom-right
              - cd ~/.emacs.d/elisp/org-mode
              - module load gcc/6.1.0    # Needed for ob-fortran tests to pass when doing make test for Org
      - window_name: foo-1
        layout: even-horizontal
        shell_command_before:
          - bob
          - cduh
        panes:
          - null
          - null
          - null
      - window_name: foo-2
        layout: tiled
        shell_command_before:
          - bob
          - cduh
        panes:
          - null
          - null
          - null
          - null
      - window_name: uvm_lib
        layout: tiled
        panes:
          - cd ~/gitlab/bar_uvm_lib
      - window_name: sandbox
        layout: even-horizontal
        panes:
          - null
          - null
          - null
      - window_name: hugo
        layout: tiled
        panes:
          - shell_command:
              - cd '~/downloads/git'
          - shell_command:
              - cd '~/e/elisp/ox-hugo/example-site'
              - ./srv
          - shell_command:
              - cd '~/hugo'
          - focus: true
            shell_command:
              - cd '~/e/elisp/ox-hugo'
      - window_name: nim
        layout: even-horizontal
        panes:
          - cd ~/sandbox/nim
          - cd ~/sandbox/nim
          - focus: true
            shell_command:
              - cd ~/sandbox/nim/chat
      - window_name: tok
        layout: even-horizontal
        shell_command_before:
          - tok
          - cduh
        panes:
          - null
          - null
          - null
      - window_name: zoo
        layout: even-horizontal
        shell_command_before:
          - bob
          - cduh
        panes:
          - null
          - null
          - null

Re: Ask HN: What are your favorite terminal programs?

#175
post #130

Earlier quoted context omitted.

Thanks for your inputs. A few comments: I first created that script called m years ago on some Unix boxes that I was using. Could have been HP-UX or other version. And I've used it over the years on many Unix and Linux versions that I worked on. It could be that in some cases, the script is needed due to a tty or TERM or other configuration issue. But I'm pretty sure that I've had the need for it (to remove those con…

Yeah I'm familiar with groff et al. I used to get this issue on old UNIX boxes but not seen it in any of the Linux distros I use daily (not Freebase). The other thing worth trying is seeing whether your locals are set correctly and/or set the GROFF_TYPESETTER environment variable. Though this might only by GNU specific. Or just redirect the output (as suggested by the other reply) which is how I used to get around th…

I don't think I have any GROFF* variables set.

Thanks again.

Re: Ask HN: What are your favorite terminal programs?

#176
post #139

Earlier quoted context omitted.

Also see the man page for the col command, which is used in my m script: http://man7.org/linux/man-pages/man1/col.1.html

I don't make a habit of commenting on shell scripts what I haven't first read. But thank you all the same. I used to use 'col' alot to resolve the tabs Vs spaces problem with different actors imposing different preferences in their source code. It's a handy tool but often overlooked.

>I don't make a habit of commenting on shell scripts what I haven't first read. But thank you all the same.

Sorry, I should have added "if you haven't already read it", in my earlier comment.

>I used to use 'col' alot to resolve the tabs Vs spaces problem with different actors imposing different preferences in their source code. It's a handy tool but often overlooked.

Interesting, I may not have noticed or known about the tabs option of col. Cool. Seems it is like the entab program in an edition of the K&R C book.

https://www.google.co.in/search?q=kernighan+and+ritchie+c+pr...

Re: Ask HN: What are your favorite terminal programs?

#177
post #154
post #97

Earlier quoted context omitted.

> Also, for saving (and then viewing) man pages (about commands or other topics), without the formatting characters (such as ^H), on some Linux distros, I find this useful: ^H is one of the two backspace characters (the other being ^?) depending on which VT standard you're configured to use. So you shouldn't really need a dedicate script to do that as it's just a problem between your pseudo-TTY (Linux console) and yo…

> you shouldn't really need a dedicate script to do that It isn't because the terminal is mis-configured and/or mis-interpreting those characters, it's because these characters have historically been used in a special way by troff's ascii output driver, as used by the man command. Bold characters are "emulated" by outputting the character itself, followed by ^H, then by repeating the character, and underline is emula…

You described the issue and cause better than I did :)

I didn't know about the ANSI behavior, interesting.

>FWIW, if you need a fool-proof way to convert a man page to plain old ASCII with no escapes at all, it's easiest just to redirect the output of "man" to a file:

> man ls > ls.txt

IIRC, even with that way, the control chars still appeared in the file (at least on some Unix version), which is why I wrote the script in the first place.

Re: Ask HN: What are your favorite terminal programs?

#178
post #154
post #97

Earlier quoted context omitted.

> Also, for saving (and then viewing) man pages (about commands or other topics), without the formatting characters (such as ^H), on some Linux distros, I find this useful: ^H is one of the two backspace characters (the other being ^?) depending on which VT standard you're configured to use. So you shouldn't really need a dedicate script to do that as it's just a problem between your pseudo-TTY (Linux console) and yo…

> you shouldn't really need a dedicate script to do that It isn't because the terminal is mis-configured and/or mis-interpreting those characters, it's because these characters have historically been used in a special way by troff's ascii output driver, as used by the man command. Bold characters are "emulated" by outputting the character itself, followed by ^H, then by repeating the character, and underline is emula…

>Pagers like "more" & "less" have in-built behaviour that knows how to interpret these sequences and render bold or underline appropriately,

Right

>and if you "cat" the file your terminal would probably ignore them

I think the terminal does not ignore them. My guess is that it interprets the characters, but it has no noticeable visual effect on the screen. E.g. if the letter "c" in "cat" is output as "c^hc" (to make in bold in print), the terminal will just print "c", a backspace, then "c" again, which to the user will look the same as a single "c".

Re: Ask HN: What are your favorite terminal programs?

#179

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10 1 167 16.7% git 2 130 13% ll 3 94 9.4% clear 4 90 9% make 5 80 8% cd 6 57 5.7% e 7 52 5.2% cat 8 45 4.5% man 9 38 3.8% valgrind 10 37 3.7% rm Where ´e´ is an alias for ´vim´.

Using zsh the equivalent command is ->% zsh_stats Sample: 1 102 15.4545% ls 2 53 8.0303% sudo 3 33 5% vim 4 30 4.54545% python 5 29 4.39394% cd 6 20 3.0303% P 7 18 2.72727% which 8 17 2.57576% pip 9 15 2.27273% touch 10 15 2.27273% la 11 13 1.9697% git 12 12 1.81818% kill 13 12 1.81818% PS 14 11 1.66667% ~ 15 10 1.51515% ln 16 10 1.51515% jobs 17 10 1.51515% cat 18 9 1.36364% take 19 8 1.21212% ~\n 20 8 1.21212% snap

Re: Ask HN: What are your favorite terminal programs?

#180
* exiftool - photo metadata editing tool

* dcraw - RAW photo processing tool

* imagemagick - image processing library

* pandoc - convert one file into another

* diceware - random word generator (useful for creating passwords)

* csvtomd - convert csv files to markdown tables

* newsbeuter - RSS reader

* zathura - pdf viewer

* weechat - irc client

* ncdu - interactive disk usage

* ranger - file manager

* mpd - music player daemon

* vimpc - vim inspired client for mpd

Post reply on HN