You are not logged in.
#!/bin/sh
# dirpipe.sh: generates an Openbox pipe menu of directories
terminal="uxterm"
user_shell="/bin/bash"
self="$0"
current_dir="$1"
if [ ! $current_dir ]; then current_dir="$HOME"; fi
echo "<openbox_pipe_menu>"
cat <<END
<item label="Shell here..."><action name="execute"><execute>$terminal -e "cd '$current_dir'; $user_shell"</execute></action></item>
<separator/>
END
cd "$current_dir"
for i in *; do
if [ -d "$i" ]; then
cat <<END
<menu id="$i" label="$i" execute="$self '$current_dir/$i'"/>
END
elif [ -e "$i" ]; then
cat <<END
<item label="$i"><action name="execute"><execute>mimeopen -n '$current_dir/$i'</execute></action></item>
END
fi
done
echo "</openbox_pipe_menu>"
It accepts one argument, the directory which it creates an entry for; if no argument is given, or the directory doesn't exist, it defaults to your home directory. Files of all types are opened with mimeopen (from perl-file-mimeinfo). The terminal and shell can of course be changed be editing the beginning of the script.
Be warned that this script calls itself recursively, so you may get a lot of sh processes when scrolling through deeply nested directories! Not sure if there's any way to fix that, unfortunately.
Edit: removed superfluous IFS line.
Last edited by Gullible Jones (2012-12-24 15:37:34)
Offline
current_dir="$1"
if [ ! $current_dir ]; then current_dir="$HOME"; fi
Could be
current_dir=${1:-$HOME}
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Less readable to those new to shell scripting (like me, har har). Thanks though.
Offline
Out of curiosity, are you aware of ObFileBrowser?
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
If I was, I'd forgotten about it. I do know of another one written in Python though.
(Reinventing the wheel is fun. And sometimes educational.)
Offline
(Reinventing the wheel is fun. And sometimes educational.)
Indeed. I've done it several times myself, often just to explore an idea.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline