Back to the newest entries in Olli's Journal
Why doesn't this application exist?
Most of the time, while working on the command line, I want to do one of two things: enter a directory or edit a file. It often goes like this: Okay, "first I need to go to that directory" (types: "cd dir " and presses tab to complete the name or to see the listing of matching dirs/files - like Bash does), "ok, it's in that subdirectory) no, in that one inside it (now the command line contains "cd directory/subdirectory), "... okay and that's the file I want". What happens is I end up pressing enter after writing to the command line something like "cd directory/subdirectory/subdir2/file.php". This can also happen to the other direction: I start with the command "pico" and end up wanting to 'cd' to a directory I've selected instead since I'm not so sure which file I want to edit after all. The result, of course: the command I enter doesn't work.
Now I'm asking: couldn't it? Why isn't there a "magic" command in *nix command line, say Bash, which would work like double click in Nautilus on Konqueror (or Explorer in windows) - just do whatever is appropriate for the filesystem item in question!
2006-09-15: I mentioned this "issue" of mine to Iikku, and he decided it's too easy, so we did it :)
The script was named "ok" by iikku, so here comes my ok.sh. To get it working, you'll have to download it to your home directory and say "source ok.sh" in your .bash_profile, if you use Bash in Linux. Ahh, another reason not to use Windows.
#!/bin/bash
ok_func()
{
if [ -f "$1" ]; then
pico $1
fi
if [ -d "$1" ]; then
cd $1
fi
}
alias ok=ok_func
Note: Of course Iikku's original version used Vim, cos', you know, he's funny that way ;). Of course I'd like to use Vim, too, someday, if I only weren't too lazy to learn all of those commands. Note 2: Of course this doesn't actually have associations for different file types, but then -- all I mostly do on the command line is usually entering directories or editing files.
September 11, 2006 22:52 in tech
Comments
No comments yet
What is this?
A Christian student writing about life, faith, software etc. both in English and in Finnish. Some photos and poetry, too. Not thinking much about whether I'm being interesting or not. See also my work blog: Moodle Quiz UI
Please comment. Anything :).
Helsinki time, GMT+2.

