Skip to content

Instantly share code, notes, and snippets.

@oodavid
Created April 6, 2012 13:39
Show Gist options
  • Save oodavid/2319878 to your computer and use it in GitHub Desktop.
Save oodavid/2319878 to your computer and use it in GitHub Desktop.
XFCE - "Open any file" via Keyboard Shortcut

Linux - "Open any file" via Keyboard Shortcut

Assign this little shell script to a keyboard shortcut Xfce to open a shell -prompt, then have that file / directory opened by it's native program.

Pretty simple, excellent user-experience!

Thanks to Xfce forum member "ToC" who helped me solve a problem with the script

How to install

  • Download the shell script to your home folder (or wherever)
  • Make it executable
    • chmod +x ./openanyfile.sh
  • Open your Keyboard Settings: Menu > Settings > Keyboard > Application Shortcuts
  • Add a new shortcut with the following command and shortcut:
    • exo-open --launch TerminalEmulator /home/david/openfile.sh
    • CTRL + SHIFT + ALT + O

Give it a go!

Port this script!

It should be trivial to port this script for GNOME / KDE / Fluxbox / OpenBox etc

#!/bin/bash
# Be pretty
echo -e " "
echo -e " . ____ . ______________________"
echo -e " |/ \| | |"
echo -e "[| \e[1;31m♥ ♥\e[00m |] | Xfce - Open any file |"
echo -e " |___==___| / \e[1;30m© oodavid 2012\e[00m |"
echo -e " |______________________|"
echo -e " "
# CD to the home folder (not sure if this is needed, no harm either way)
cd ~/
# Request the filepath
echo -e "\e[1;31mEnter a file or directory:\e[00m"
read -e -i "~/" filename
# Convert ~/ to /home/username/
filename=`eval "echo $filename"`
echo -e "opening\e[1;32m" $filename "\e[00m"
# Open the file
setsid exo-open "$filename"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment