Thursday, April 11, 2019

Terminal commands tips and tricks

Run the code in python or node.js

#: python -c "print 2+3"
#: nodejs -e "console.log(2+3)"

Launching a static web server in the current folder

#: python -m SimpleHTTPServer 8000

Work with the system clipboard

I use xsel utility to copy text in the system clipboard.
Copying the path of current folder with xsel:
#: pwd | xsel -b

To copy specific line and range of lines from a file:
#: sed -n '180p' file.txt | xsel -b
#: sed -n '180,182p' file.txt | xsel -b

Download collection of links

I use wget utility with i flag to download resources from the file one by one:
#: wget i <filepath>

Opening a image viewer from the console

#: gpicview <file path>
Where GPicView is a default image viewer in Lubuntu.

Terminal hot keys:

[Ctrl A] move to the beggining of the line

[Ctrl E] move to the end of the line