Know Your Command Line – InApps Technology is an article under the topic Software Development Many of you are most interested in today !! Today, let’s InApps.net learn Know Your Command Line – InApps Technology in today’s post !
Read more about Know Your Command Line – InApps Technology at Wikipedia
You can find content about Know Your Command Line – InApps Technology from the Wikipedia website
<strong>Computer Terminal. </strong><em>noun. </em><em><span class=“uk”><span class=“pron”>/<span class=“ipa”>kəmˈpjuːtə ˈtɜːmɪnəl<span class=“sp”>r</span></span>/
</span></span></em>A computer terminal is an electronic or electromechanical hardware device that is used for entering data into, and displaying data from, a computer or a computing system.
Actual hardware computer terminals may be a thing of the past when for $700 in 1978, you could get a real VT100 terminal that connects you to an actual computer. You would send commands on a CRT screen and wait for the remote machine to send you back the response. Computing then was fun. And tough.
Today, we have multi-core processing power in the palm of our hands. Even then, we still are faced with GUI-less, barebone computers. Embedded system developers and sysadmins will surely concur when I say that, terminals have not died. They’ve merely been replaced with Terminal Emulators.
Embedded developers are routinely presented with a simple serial interface to an ARM9 board with no other option but to use vi, nano and related tools to get things done on the embedded target. Sysadmins may be digging deep into those suspicious log messages on a remote server in Singapore over SSH. Want to administer your new droplet on Digital Ocean? There is a console for shell access in a browser for that! Want to play with that new VM on OpenStack? Well, just SSH to get shell access and you are good to go.
Apart from the occasional necessity, command line and terminal interface is extremely productive and efficient for getting things done. Lots of developers spend their time handling large quantities of text and keeping computer interaction in the text space only removes a lot of distraction and unnecessary hand movements. And let’s not forget that terminals do really ante up the geek factor in you!
These days, the way to the command line awesomeness is a terminal emulator. It actually emulates how an old age TTY terminals or their successors would connect to the host machines. A modern terminal emulator on your Linux or Mac (henceforth called as a terminal) creates a virtual command line interface to the host (the same computer usually) so that you get a similar feel from the 60s and 70s in 2015. There are many terminal emulators available such as Konsole, Gnome-terminal, iTerm or xterm, but my favorite is Terminator. Let’s see some of the tools for the everyday geek who wants to use email, play songs or browse files at the most.
Before be begin with the tools, let’s pretty up the command prompt, shall we? How about converting your default prompt to something like this:
This nifty tool has roots in a Vim related project called as powerline. In fact, it just “skins” your current shell prompt and adds some nice features to it. For example, showing current git branch, highlighting your home directory, showing locks if the directory you are accessing is not writeable etc.
For a similar uniform UI for shell and other tools like Tmux and Vim, install powerline for each of them. We will come to that a bit later. For now, you can install it on Fedora thusly:
$ sudo dnf install powerline
If you are running other shells like zsh, see the documentation for details on how to set it up.
Now, let’s organize your terminal behavior.
Imagine 10 screens all shown to you as and when required and the ability to mirror them, attach/detach them to and from any local or remote machine over ssh. How does that sound? Tmux is terminal on steroids running inside another terminal and is one of the most useful tools that you will come across. Your workflow can involve multiple tmux screens spawned in your work computer which can be controlled from your home machines by mirroring them or detaching them and then reattaching them in the new session. This is similar behavior than GNU Screen utility but with added advantage of windows, split-panes and what not.
Here is a nice tmux cheat-sheet to get you started. Have a look how I attach a Tmux session named work on my remote machine, continue working on it and then eventually detach it and reattach a fun session (assuming I have SSHed to isengard). The work session also has split-panes which can be set from within a Tmux session.
To install Tmux and its Powerline UI look along with it,
$ sudo dnf install tmux tmux–powerline
Then in the
~/.tmux.conf file add the following lines:
set –g default–terminal “screen-256color”
With some imagination, you can use Tmux to do cooperative coding or even remotely teach some tricks to your peers at the workplace as the Tmux screens actually act like “mirrored terminals.”
Mutt is a minimal email client which gives you a ncurses based Textual User Interface (TUI). This is the most minimal and yet functional approach to mail for terminal aficionados. There is a bit of inertia during the manual configuration required in the beginning, but once you are done browsing and replying to keystrokes will be just a few keystrokes.
For starters, here is a very quick and dirty
.muttrc file that you can place in your home directory and with some minor tweaks you can access your mail.
SCRIPT FILTERED: gist.github.com
Keep in mind that the default mutt will not show you the sidebar as shown above. For that, you need a sidebar-patched mutt version. I am using this COPR repo for my Fedora 22 machine. If you use this repo, just do,
$ sudo dnf install mutt–kz
There is a similar version for Ubuntu too. For the monokai color-scheme as shown in the image, you can use the color configuration from here and add it to the .muttrc file. A few years back, Steve wrote an ultra-detailed guide called The Homely Mutt which can be an inspiring read as well.
Probably a browser with the least features on any machine would be lynx. However, it has saved me a few clicks many times when I have to look up some reference or a manual page on the web and I don’t want to move away from the command line. Opening a new browser, for a familiar website and then browsing pages sometimes takes more time than anticipated. You can quickly open a URL by pressing g. Follow the link using Right Arrow or Enter and go backward using Left Arrow. To explore more lynx options and settings, press o. To search on a page, you can just press / followed by your query. Then navigate the highlighted search using n and p. For example, here is a screencast of me browsing kernel documentation on a specific topic quickly and getting back to what I was working on:
Everyone loves music. But now, you can play music in minimal style using Cmus. For Fedora, though, you would have to build cmus from source. Once installed, you can start by cycling through multiple “windows” using numbers 1 – 7. For example, press 5 to open the browser, select your album directory and press a to add it to cmus library. Press 2 to go to library playlist, select a track and hit Enter to play. You can play/pause using c and stop the playback using v. Here is a short cmus screencast to give you a feel oh how it looks:
There are many other shortcuts. To get the monokai color scheme for uniformity, use this theme by Hyoshida. Just add it to ~/.config/cmus/rc. You can explore more from the man pages using,
$ man cmus
$ man cmus–tutorial
Well, we all know that on a terminal nothing can be as fast as a simple
mv and occasionally tree for managing files on Linux. But if you want to explore the filesystem more visually, Ranger is the tool of choice.
There are other tools like Midnight Commander, but I personally prefer ranger because it has similar bindings like Vim and is very intuitive to use. There are just two main keys for exploring your files: Right Arrow to go deep in folders and Left Arrow to go back. You can use y to copy and p to paste or press Delete followed by Enter to delete your files. In the screencast, you can see how I am exploring a directory and previewing the files
Another cool thing about ranger which you must have observed from the screencast is the ascii preview of your image which is done using
img2txt. For that, you need two things, one is the
img2txt tool which you can install along with ranger as,
$ sudo dnf install ranger img2txt
The other thing is the
scope.sh file which essentially helps ranger choose which tool to use for preview for a specific filetype. I have used this scope.sh file and modified it a bit for my needs. You can place this in
~/.config/ranger/directory. You will also need another file
~/.config/ranger/rc.conf with the following content to set previews on and show borders like in the screencast
set preview_images true
set draw_borders true
There are many other great command line tools that I may have missed, but I hope this is enough for now. In my next chapter of “Terminal Essentials,” I will discuss some nice tools for developers and sysadmins and share some of my own configurations with them. And of course, don’t forget to have fun on the terminal. Here is a final screencast for you while I board my Christmas holidays train!
Digital Ocean is a sponsor of InApps Technology.
Feature Image by Jason Scott, licensed under CC-BY-2.0.
Let’s create the next big thing together!
Coming together is a beginning. Keeping together is progress. Working together is success.