Tag Archives: cli

Search DuckDuckGo from the Command Line

When we showed you how to search Google from the command line a lot of you to say you use Duck Duck Go, the awesome privacy-focused search engine. Well, now there’s a tool to search DuckDuckGo from the command line. It’s called ddgr (pronounced, in my head, as dodger) and it’s pretty neat. Like Googler, ddgr […]

This post, Search DuckDuckGo from the Command Line, was written by Joey Sneddon and first appeared on OMG! Ubuntu!.

Read More

Command Line Music Player for Spotify, YouTube & Other Music Streaming Services

youtube music logoTizonia is a command-line music player that lets you listen to music on Spotify, Google Play Music, YouTube and Soundcloud from the terminal.

This post, Command Line Music Player for Spotify, YouTube & Other Music Streaming Services, was written by Joey Sneddon and first appeared on OMG! Ubuntu!.

Read More

Finding Files in the Command Line

Unfortunately in Linux, certainly Ubuntu, the default GUI file search is not the most useful way to find files. With just a small amount of patience you can find files quickly and easily using the command line, and your options for this are really powerful if you want to learn a bit about it. Locate The […]

This post, Finding Files in the Command Line, was written by Nixie Pixel and first appeared on OMG! Ubuntu!.

Read More

Streamlink 0.5.0 Adds Support For Streaming Google Drive / Google Docs Videos

Streamlink 0.5.0 was released yesterday, bringing support for streaming videos from Google Drive / Google Docs, along with other improvements.

Streamlink

Forked from Livestreamer, which is no longer maintained, Streamlink is a command line tool (and API) that can be used to stream videos from various streaming services, such as Twitch, YouTube Live and many more, and play them using your favorite video player, be it VLC, mpv, and more.

It is is available for Linux, Windows, and Mac OS.

Changes in Streamlink 0.5.0 include:

  • added support for streaming videos stored on Google Drive / Google Docs;
  • added support for BBC iPlayer live and VOD, along with support for HLS streams;
  • add support for Beam VOD and HLS streams for live;
  • added support for camsoda.com;
  • added new plugin: canlitv;
  • added new plugin: garena;
  • Aliez plugin now accepts any TLD;
  • added support for avi/mov VOD streams for rtve;
  • removed dead plugins such as blip.tv, gaminglive.tv, leon.tv, livestation.com and more.

Since our initial article about Streamlink, the tool has seen quite a few improvements, including support to use FFmpeg to mux separate video and audio streams, along with new plugins and much more. Check out the Streamlink GitHub releases page for a complete changelog.

For a complete list of supported streaming services, see THIS page.

Using the Streamlink command line interface is very simple. Here’s an example using a Google Drive video. The first thing you need to do is run Streamlink with the link you want to stream, to see the available streams:

streamlink https://drive.google.com/open?id=0B0tRrdcY7CwJWGdVdHEyYWpfTTQ

This should list the available formats:

[cli][info] Found matching plugin googledrive for URL https://drive.google.com/open?id=0B0tRrdcY7CwJWGdVdHEyYWpfTTQ
Available streams: 360p_alt, 480p_alt, 360p (worst), 480p, 720p, 1080p (best)

Next, simply add one of the available streams at the end of the command, and Streamlink will start streaming:

streamlink https://drive.google.com/open?id=0B0tRrdcY7CwJWGdVdHEyYWpfTTQ 1080p

By default, Streamlink uses VLC to play the stream, but you can specify a different video player by using the “–player” argument, e.g. “–player mpv” to use mpv instead.

For more about using the Streamlink command line interface, check out THIS page.

Install Streamlink

Ubuntu / Linux Mint users can install Streamlink by using the main WebUpd8 PPA. To add the PPA and install Streamlink, use the following commands:
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt update
sudo apt install streamlink

I didn’t add a direct deb download link because the PPA provides quite a few dependencies required to install Streamlink.
For how to install Streamlink in other Linux distributions, Windows or Mac OS, see THIS page.
Report any bugs you may find @ GitHub.

Read More

Automatically Organize Your Downloads Folder In Linux Using `Classifier` (Command Line)

My downloads folder is pretty messy but I can’t just delete things because I still need most of the stuff I download. To “fix” this, I was looking for an app that can automatically organize my downloads, and I stumbled upon Classifier, an easy to use command line tool that can organize files in any directory.
Here’s an example – on the left there’s a folder which contains various file types (images, archives, documents, etc.) and on the right it’s a folder that contains the exact same files as the folder on the left, but after running Classifier to organize it (into folders):

classifier organize folder

Classifier organizes a directory based on file extension, moving the files into specific folders, like music, documents, images and so on.
I should also note that while this article mentions organizing the downloads folder, Classifier can be used to organize files in any any directory.

To organize files in the downloads (~/Downloads) folder, either run Classifier in that folder with no arguments, e.g.:

cd ~/Downloads
classifier

Or specify the directory as an argument, like this:

classifier -d ~/Downloads

Classifier can also organize specific file types that aren’t classified by default, organize by creation date and more. You can find a few examples on its GitHub page.

Here are all Classifier options:

$ classifier --help
usage: classifier [-h] [-st SPECIFIC_TYPES [SPECIFIC_TYPES ...]]
[-sf SPECIFIC_FOLDER] [-o OUTPUT] [-d DIRECTORY] [-dt]

Organize files in your directory instantly,by classifying them into different
folders

optional arguments:
-h, --help show this help message and exit
-st SPECIFIC_TYPES [SPECIFIC_TYPES ...], --specific-types SPECIFIC_TYPES [SPECIFIC_TYPES ...]
Move all file extensions, given in the args list, in
the current directory into the Specific Folder
-sf SPECIFIC_FOLDER, --specific-folder SPECIFIC_FOLDER
Folder to move Specific File Type
-o OUTPUT, --output OUTPUT
Main directory to put organized folders
-d DIRECTORY, --directory DIRECTORY
The directory whose files to classify
-dt, --date Organize files by creation date

Since the tool organizes files only when it’s ran, and you may not want to run it manually every day / hour, etc., you can create a cron job to run it periodically. For those who are not very familiar with Cron, here’s an online crontab generator (use the full path to the classifier executable in the crontab if you install it using the instructions in this article).
Important: Classifier doesn’t display any warning or confirmation when moving files, and there’s no way to undo any operations it performs, so make sure you run it in the correct folder and / or with the correct arguments!

Tip: for a somewhat similar tool which doesn’t organize folders based on file types, but based on when the files were last accessed, check out Download Sweeper.

Install Classifier

1. Classifier can be installed using Python pip (you’ll also need python-setuptools). To install python-pip and python-setuptools in Ubuntu, Debian, Linux Mint and other Debian-based Linux distributions, use the following command:
sudo apt install python-pip python-setuptools

2. Next, install Classifier (for the current user only) using the commands below (the first command installs wheel because it looks like the installation fails if it’s not installed first):

pip install --user wheel
pip install --user classifier

3. The Classifier executable is installed under ~/.local/bin, and this may not be in your PATH by default. To add ~/.local/bin/ to your PATH, paste PATH=”$HOME/.local/bin:$PATH” in your ~/.bashrc file (replace it with ~/.zshrc if you use Zsh) file. You can use the command below to do this from a terminal:

echo "PATH="$HOME/.local/bin:$PATH"" >> ~/.bashrc

And finally, source the ~/.bashrc (or ~/.zshrc if you use Zsh) so the new configuration is used in the current terminal (opening a new shell should work as well):

. ~/.bashrc

(there’s a dot, then a space followed by ~/.bashrc)

Later on, if you want to update Classifier, use the following command:

pip install --user --upgrade classifier

To download the Classifier code, report bugs, etc., see its GitHub page.

Read More

Uber CLI: Quickly Get Uber Time-To-Pickup And Price Estimates From The Command Line

uber logo

Uber CLI is a tool to get time-to-pickup and price estimates for Uber from the command line. The application cannot be used to request Uber rides.

This is useful if you use Uber and the command line a lot, as it’s much faster than checking these details on your phone, especially if you create some Bash aliases for your home address and the places you frequently use Uber to get to.

The developer says that he created Uber CLI because “[…] as a lazy person it pains me every time [I] open my phone, open the Uber app, type my destination, and see the estimated price, only for my inner, responsible, cost-cutting, fiduciary-self to end up taking the bus all the way home. I think we can all agree that it would be much more efficient to simply be disappointed before I open my phone at all”.

Installing and using Uber CLI

1. To install Uber CLI, you’ll need Node.js and npm.

For Ubuntu 16.04 and newer, you can use the Node.js and npm packages from the official repositories:

sudo apt install nodejs npm

For Ubuntu versions older than 16.04, you’ll need a newer Node.js/npm version. This can be installed by using the official Node.js repository. You’ll find exact instructions HERE (in my test I installed Node.js 6.x in Ubuntu 14.04 and uber-cli installed without any issues).

2. Install Uber CLI

Before proceeding, you may wish to set up npm to allow installing packages globally without sudo. For how to do this, see our previous article. You can skip this and use the command below with sudo, but that’s not recommended!

To install Uber CLI, simply type the following command in a terminal:

npm install uber-cli -g

That’s it. You can now start using Uber CLI. To get a time-to-pickup estimate, use the following command:

uber time 'pickup address'

replacing ‘pickup address’ with the address the Uber ride should pick you up.

Here’s an example:

$ uber time '10 downing street london uk'
┌───────────────────────────────────────────────────┐
│ 10 Downing St, Westminster, London SW1A 2AA, UK │
├──────────────────┬────────────────────────────────┤
│ │ │
├──────────────────┼────────────────────────────────┤
│ 2 min. │ uberPOOL,uberX,uberXL │
├──────────────────┼────────────────────────────────┤
│ 4 min. │ UberEXEC │
├──────────────────┼────────────────────────────────┤
│ 6 min. │ UberLUX │
├──────────────────┼────────────────────────────────┤
│ 8 min. │ uberASSIST │
├──────────────────┼────────────────────────────────┤
│ 17 min. │ uberWAV │
├──────────────────┼────────────────────────────────┤
│ 14 min. │ taxi │
└──────────────────┴────────────────────────────────┘

You may skip the city and country – in my test, this worked without any issues, but I assume it is required in cases where there are multiple streets with the same name, etc.

To get price estimates, use the following:

uber price -s 'start address' -e 'end address'

replacing the start and end addresses with the actual locations.

Here’s an example:

$ uber price -s '10 downing street london uk' -e '221b baker street london uk'
┌────────────┬───────────────────────┬──────────┬─────────┬──────────┐
│ │ │ │ │ Surge │
├────────────┼───────────────────────┼──────────┼─────────┼──────────┤
│ uberPOOL │ £10-£11 │ 3.74 mi. │ 20 min. │ │
├────────────┼───────────────────────┼──────────┼─────────┼──────────┤
│ uberX │ £9-£12 │ 3.74 mi. │ 20 min. │ │
├────────────┼───────────────────────┼──────────┼─────────┼──────────┤
│ uberXL │ £13-£17 │ 3.74 mi. │ 20 min. │ │
├────────────┼───────────────────────┼──────────┼─────────┼──────────┤
│ UberEXEC │ £17-£23 │ 3.74 mi. │ 20 min. │ │
├────────────┼───────────────────────┼──────────┼─────────┼──────────┤
│ UberLUX │ £27-£35 │ 3.74 mi. │ 20 min. │ │
├────────────┼───────────────────────┼──────────┼─────────┼──────────┤
│ uberASSIST │ £9-£12 │ 3.74 mi. │ 20 min. │ │
├────────────┼───────────────────────┼──────────┼─────────┼──────────┤
│ uberWAV │ £9-£12 │ 3.74 mi. │ 20 min. │ │
├────────────┼───────────────────────┼──────────┼─────────┼──────────┤
│ taxi │ ?undefined-?undefined │ 3.74 mi. │ 20 min. │ │
├────────────┼───────────────────────┴──────────┴─────────┴──────────┤
│ │ 10 Downing St, Westminster, London SW1A 2AA, UK │
├────────────┼───────────────────────────────────────────────────────┤
│ │ 221B Baker St, Marylebone, London NW1 6XE, UK │
└────────────┴───────────────────────────────────────────────────────┘

The blank cells in the examples above are Emoji, but I removed them so the columns don’t get messed up. To get Emoji support in Linux, install the EmojiOne Color SVGinOT font (but note that it doesn’t work properly with monospace formatted text and causes incorrect character alignment, or at least that’s the case at the time I’m writing this).

app seen @ desdelinux.net

Read More

Configure npm To Install Packages Globally Without sudo Using A Script

npm logo

npm is the default package manager for Node.js. It consists of a command line client that integrates with a remote registry, and it makes it easy to install, share and distribute code.

If you’re using npm installed from a repository in Linux (like the official Ubuntu or Node.js repositories), you may have noticed that you can’t install packages globally (“-g”) as a regular user. Many websites mention installing npm packages using sudo, but this messes up some permissions and is not recommended.

The easiest way to get npm to download packages globally without sudo (“npm install -g <package>”) in Linux is to use a script, called npm-g_nosudo, to automatically set everything up.

The script GitHub page mentions that it was tested on Ubuntu 14.04 with Bash, but I don’t see why it wouldn’t work in other Linux distributions.

As an alternative, you can use THESE instructions to set up npm to install packages globally without sudo in Linux.

Here’s what the npm-g_nosudo script does:

  • creates a backup list of your installed npm packages and removes all but npm;
  • then it creates a local directory and configures node to use this for global installs (~/.npm-packages); this (optionally) includes adding the local directory and bin paths to ~/.bashrc or ~/.zsh;
  • it fixes permissions for the ~/.npm directory;
  • and finally, it reinstalls the old packages.

The reason behind publishing this article is to be able to link to it in future posts that mention installing npm packages, to make it easy for users to install them the recommended way – without sudo.

Another way of installing packages with npm in Linux without sudo is by using NVM to install Node.js, instead of a repository.

Configure npm to install packages globally without sudo on Linux (using npm-g_nosudo)


Before proceeding, it’s important to mention that you should never run scripts without understanding what they do. So take a look at the npm-g_nosudo script before running it!

To download the npm-g_nosudo script and run it, use the following commands:

cd && wget https://raw.githubusercontent.com/glenpike/npm-g_nosudo/master/npm-g-nosudo.sh
chmod +x npm-g-nosudo.sh
./npm-g-nosudo.sh

The script will ask you to choose the install directory – you can press ENTER to use the default directory (~/.npm-packages). The second and final step is to choose if if you want to update ~/.bashrc and ~/.zsh with the new paths – type “y” and press ENTER to do this automatically, or “n” to perform these changes manually.

Once you’re done, remember to source ~/.bashrc or ~/.zsh, depending on what you use (or launch a new terminal):
– for Bash:

source ~/.bashrc

– for Zsh:

source ~/.zsh

Read More