Home > bash > Google Nexus device in the filesystem

Google Nexus device in the filesystem

I got a Google Nexus tablet that I can manage with Nautilus (Ubuntu) / Thunar (Manjaro). However, it would be nice to manage this device with Midnight Commander too.

If the graphical file manager shows the address “mtp://[usb:007,005]/” for instance, then you will find it in the file system at “/run/user/1000/gvfs/mtp:host=%5Busb%3A007%2C005%5D“.

However, if you connect the device to a different USB port, the address will be different from “mtp://[usb:007,005]/“.

To enter the root directory of the device, I have the following script:

#!/usr/bin/env bash

cd /run/user/1000/gvfs/
cd `ls`
cd "Belső tárhely"

How to call it in the command line: “. nexus“. The script is called “nexus” in my case. Notice the “.” in front of it, which is an abbreviation for the command “source“.

Categories: bash Tags: , , ,
  1. November 7, 2014 at 21:58

    If I’m not mistaken technically you should only source scripts that operates at environment level and only when looking to modify the current shell instance; I think that for what you’re looking to achieve it would be better to place the script in a directory parsed by your $PATH variable.

    • November 8, 2014 at 12:59

      I want to modify the current shell instance. After executing the script, I want to find myself in the root directory of Nexus. Let’s take an example. Write a script called “eh.sh” with the content “cd /tmp“. Make it executable and run it from your home directory: “$ ./eh.py“. Nothing happens, you are still in the home directory. The script is executed in a subprocess, and a subprocess cannot modify the parent process. But! If you execute with “. eh.py“, which stands for “source eh.py“, you will find yourself in /tmp. The command “source” executes the script in the current shell process, and in this case this is what I wanted.

      • msx
        November 8, 2014 at 21:29

        (I’m M.C. logged with other account)
        Ha! Lovely hack!

  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: