This is a gathering of shell commands or tools that look interesting - some are amazing.
The list is in alphabetical order.
ag
ag
, the silver searcher, is a tool similar to ack
. Well, I have been using grep
only all the time.
But indeed, ag
is fast, and by default it does recursive search, returns line numbers too, and have highlighting. So I probably would migrate from grep
to ag
. One thing to note, since it’s recursive, it’s necessary to specify the scope of search. One can use -G [regexpr]
for files to include, and --ignore [regexpr]
to exclude some files.
There is a good guide for this tool.
cloc
cloc
stands for “Count Lines of Code”. Basically it analyzes given file(s)/folder, counts the lines, returns the number of lines of code, comment, and blank. Its website provides a good introduction to this tool. There are a lot of similar tools available, as listed here. cloc
supports more languages than most of other ones.
I used to use wc
to count the sizes of my projects, which typically look like the following,
I have to use find
to identify the files I want to take into account, then send to wc
to count lines of each file, and finally output the last line, which is the sum of all lines.
With cloc
, I can simply do,
It identifies all code-related files - so I don’t need to manually exclude files related to documentation. I use doxygen
and it generates numerous html files. And it provides a summary of the code files categorized by language - provides more info than my home-made shell command.
cloc
can also diff codes. I have not seen this type of needs. When I need to compare different versions of my projects, version-control software is sufficient for me.
fasd
fasd
is tool for faster access to files and directories, as described in its webpage. It is inspired by autojump
, z
and v
. In fact, initially I wanted to write about autojump
, which is a Python-based tool. Then I came across fasd
, purely Shell. I prefer to use shell-based tool in shell. fasd
records the places one have visited, and ranks those by “frecency” i.e. “frequency+recency”, just like webpages. Later on, it would be able to guess which place to visit when the user types in only a few letters.
fasd
comes with a list of aliases. Some of them are,
My favorite is z
. Suppose I have visited a place called foo/bar
very frequently and recently, then wherever I am, I can do something like z fo
to jump to foo/bar
. fasd
just estimates where I want to go most likely. For the other three, a
, d
, and f
can be used to check the current frecency of the entries in the database.
htop
An enhanced version of top
. It visualizes the usage of the CPU, memory, and swap. More importantly, it is interactive! One can click on the entries to sort the processes. For a lazy guy like me, it saves the trouble of memorizing the short-cuts. Its functionalities are detailed in its help. Its website is pretty cool as well.
thefuck
This tool corrects the previous mis-typed console command. Its awesomeness is explained by this video. I think no more explanation is needed here.
tmux
tmux
is termed “terminal multiplexer”. According to its website, it lets you switch easily between several programs in one terminal, detach them and reattach them to a different terminal. However, I personally use terminator
, mainly for splitting the terminal into several panes for multiple tasks. It is easy to use and can record/modify the configuration just like tmux
.
There is a guy switched from terminator
to tmux
. Following advantages of tmux
are pointed out,
- Portability - tmux works on all systems able to handle plain, old terminal.
- Scriptability - tmux can be scripted, so that setting up windows and panes takes nothing more than one or two keystrokes.
- Server-client architecture - tmux can be used to share sessions between users.
- Tweaks and options - both tmux and Terminator are easy to get with, but it’s tmux that allows to go further and offers wide range of configuration hacks.
Well, the best tool is determined by the working environment, right?
yapf
yapf
stands for “Yet Another Python Formatter”. As the name indicates, there are already some Python formatter out there. These formatters try to conform the Python code with the PEP8 standard. It looks like yapf
uses some smarter algorithms for this purpose.
Well, somehow I prefer my formatting, esp. the dictionaries and argument lists. yapf
provides the identifier to avoid formatting some regions of the code,
This is not convenient enough. I would just continue to use pylint
.
you-get
you-get
behaves like wget
. As described by its webpage, it is a “Dumb downloader that scrapes the web”.
I have not used this one yet though. No such need yet.
asciinema
I ran into this when I collect materials for this post.