[HowTo] add custom scripts to Nautilus right click menu and assign keyboard shortcuts

Difficulty: ★☆☆☆☆

Copied from old forum and updated.

Similar to Thunar’s custom actions feature, Nautilus has a custom scripts feature. If you create bash scripts in the ~/.local/share/nautilus/scripts folder (you need to create this folder), they appear in the right-click menu like this:

For more details go here

Here are my basic scripts:

  • compare-files

    #!/bin/bash
    meld ./"$1" ./"$2"
    
  • convert-srt-to-utf8

    #!/bin/bash
    mv ./"$1" ./"$1.bak"
    iconv -f ISO-8859-9 ./"$1.bak" -t UTF-8 -o ./"$1"
    trash ./"$1.bak"
    
  • copy-path

    #!/bin/bash
    echo -n $(pwd)/"$1" | xclip -selection clipboard
    
  • create-backup

    #!/bin/bash
    cp -r ./"$1" ./"$1".bak
    
  • create-link-hard

    #!/bin/bash
    ln ./"$1" ./"$1".hardlink
    
  • create-link-soft

    #!/bin/bash
    ln -s ./"$1" ./"$1".softlink
    
  • edit-text

    #!/bin/bash
    kate ./"$1"
    
  • rm-rf (This one is dangerous!)

    #!/bin/bash
    rm -rf ./"$1"
    
  • search-in-folder

    #!/bin/bash
    catfish ./"$1"
    
  • show-disk-usage

    #!/bin/bash
    qdirstat ./"$1"
    
  • show-media-info

    #!/bin/bash
    mediainfo-gui ./"$1"
    
  • tar

    #!/bin/bash
    tar -cf ./"$1.tar" ./"$1"
    
  • upload-image

    #!/bin/bash
    imgurbash2 ./"$1"
    

You can also create keyboard shortcuts for your custom scripts. For example in order to open terminal in the current folder with the keyboard shortcut F4, create the below 2 files:

  • ~/.local/share/nautilus/scripts/terminal

    #!/bin/bash
    gnome-terminal
    
  • ~/.config/nautilus/scripts-accels

    F4 terminal
    

    You can add multiple keyboard shortcuts to ~/.config/nautilus/scripts-accels

    F4 terminal
    F3 rm-rf
    

In order changes to take effect, quit nautilus with nautilus -q and open it again.

What are your custom scripts?

5 Likes