Using a shell as a file browser !

pitupepito2000

Golden Member
Aug 2, 2002
1,181
0
0
Hi,

From an earlier post in which somebody asked for a file browser similar to Internet Explorer, and since somebody brought up the fact that using the command line, with a combination of scripts it's a lot faster more efficient I decided to create this post.

So the question is what are your tricks/script/command/etc that you use when browsing for files using your shell in *nix?
 

pitupepito2000

Golden Member
Aug 2, 2002
1,181
0
0
I guess I'll start.
I use a lot "ls -trhl" or "ls -trhla" when trying to list files or looking at what I named something.
For me a must is "ls --color=auto" I can't live without colors in bash
instead of using "find" I like to use "ls -trhal | less" and then within less I like to do the search.


ALIAS
rm = rm -i
mv = mv -i

That's about all what I use for file browsing using the shell. I don't have any specific scripts that I use, if I ever need to do something, I usually just write it, when I need it.

So what do you guys use?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
I haven't used mc in years. :p

Colors other me. They distract the monkey. I use ls -F constantly instead.

find is my friend. :)
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
For ls stuff, I alias ls to "ls --color=auto" and also set the following function:

lsl{ \ls --color=yes -lA $@ | less -RFX}

I'll leave it to interested readers to work out the details of that.

But that being said, and having read the earlier post, I don't really get what you mean by "browsing". I mean, certainly Nautilus or any other FM will let you look through directories, so I assume you mean more than that. Could you maybe list some tasks that you're trying to accomplish? I don't find myself using a terminal very often, apart from ssh'ing into my servers to check them out. Nautilus works fine for me as far as clicky-opening typical files, and other stuff I'll write a script for. Zenity is very handy in this regard.
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Nothing special really, I pretty much just type&go.
I hate colors, and I hate rm/mv/etc -i, unfortunately Redhat(which we use on most of out boxes at work) creates those aliases automatically.
I also hate find, it's a godawful command.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Sunner
Nothing special really, I pretty much just type&go.
I hate colors, and I hate rm/mv/etc -i, unfortunately Redhat(which we use on most of out boxes at work) creates those aliases automatically.

Ew. You can fix that though. :evil:

I like the -i flag. It comes in handy, but I like it as an option. ;)

I also hate find, it's a godawful command.

What's wrong with find? :confused:
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
/Leaves thread

Don't know what you guys are talking about :eek: but it sounds cool and I should learn Linux :(
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: screw3d
/Leaves thread

Don't know what you guys are talking about :eek: but it sounds cool and I should learn Linux :(

It's only cool if you type well. :p
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Originally posted by: n0cmonkey
Originally posted by: Sunner
Nothing special really, I pretty much just type&go.
I hate colors, and I hate rm/mv/etc -i, unfortunately Redhat(which we use on most of out boxes at work) creates those aliases automatically.

Ew. You can fix that though. :evil:
Yeah I know, but since some of the fellas here at the office use terminal applications that don't handle colors, they only get bolded text instead, and they love that, so I piss people off if I turn off the color permanently.
I do it anyways pretty often, if they expect me to fix the systems, they'd better not expect me to get a headache from working with them ;)

I like the -i flag. It comes in handy, but I like it as an option. ;)
Same here, but I prefer not to use it 95+% of the time.

I also hate find, it's a godawful command.

What's wrong with find? :confused:

Behaves differently on different platforms.
Of course since I hate it, I suck at it, so it may very well be my problem :)
Heh, only yesterday, I ran it on a box(don't actually remember what OS), it would give me a syntax error if I ran it from /etc, just changed directory to /root, ran the exact same command, and it worked fine.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Sunner
Originally posted by: n0cmonkey
Originally posted by: Sunner
Nothing special really, I pretty much just type&go.
I hate colors, and I hate rm/mv/etc -i, unfortunately Redhat(which we use on most of out boxes at work) creates those aliases automatically.

Ew. You can fix that though. :evil:
Yeah I know, but since some of the fellas here at the office use terminal applications that don't handle colors, they only get bolded text instead, and they love that, so I piss people off if I turn off the color permanently.
I do it anyways pretty often, if they expect me to fix the systems, they'd better not expect me to get a headache from working with them ;)

I like the -i flag. It comes in handy, but I like it as an option. ;)
Same here, but I prefer not to use it 95+% of the time.

I also hate find, it's a godawful command.

What's wrong with find? :confused:

Behaves differently on different platforms.
Of course since I hate it, I suck at it, so it may very well be my problem :)
Heh, only yesterday, I ran it on a box(don't actually remember what OS), it would give me a syntax error if I ran it from /etc, just changed directory to /root, ran the exact same command, and it worked fine.

Weird, I haven't noticed any syntax inconsistancies between OpenBSD, Linux, and Solaris.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
I use find, but I don't use it's weird command syntax. It annoys me. I just use it to list files properly.

The way ls should, if it's designers didn't out think themselves.

wrong way to list files(ls -R)
./directory:
filename2
filename3
filename4

./directory/directory2:
filename4
filename5
filename6

blah blah blah.


Correct way to list files(find):
./directory/filename1
./directory/filename2
./directory/filename3
./directory/directory2/filename4
./directory/directory2/filename5
./directory/directory2/filename6

What were they thinking? They figured they couldn't make it awkward enough so that they added the : on the end of the directory name too!

Anyways. I like colors very much personally. Makes it easy to find directories without having to deal with all the ls -l stuff. I find it very annoying to stare at a black and white screen.

I do a lot of:

find |grep filename
locate filename |grep /etc/
find | while read i; do echo "$i" |grep .mp3; echo "$i" |grep .ogg; echo "$i" |grep .flac; done > playlist.m3u

Stuff like that. When I do a particularly long or usefull command I'll copy and paste it into a bash script and then stick it into my ~/bin.

So I end up doing a lot of "ls ~/bin" to find stuff.

Locate is cool, but it's not going to be incredably up to date, unless you manually run updatedb if you make lots of changes.

Midnight command I never "got", I always hated using the F# buttons for lots of stuff.

I'd tried lots of GUI file managers, and so far my favorite is Gnome 2.6's spatial stuff. I still don't use that much, but I do like the ability to right click on directories and open in terminal. (choose your terminal of choice in the advanced preferences, gnome preffered applications tool)

I'd probably use that more, but more and more my favorite way of doing things is to use my laptop and have a bunch of SSH connections into everywere. Gnome's file manager is very usefull even for that, although in a more limited way. You can setup virtual folders that point to other computers thru the SFTP (and others, like ftp or other network shares) protocol. So that way I can have a folder on my laptop desktop that opens to my home folder that I can either double click on and get the spatial file manager setup or right click browse and get the browser-style file manager.

Another thing I do to make Gnome's filemanager more command line friendly is I delete the stupid Dekstop folder, and go "ln -s Desktop ~/" So that my desktop is the same folder as my home folder. That makes things easier for me.

Then I have a ~/tmp directory that I do work in like unzipping and untaring files. Compiling. A ~/work directory that I use when I screwing around with programming. (very bad programming) A ~/save directory, a ~/music, a ~/media, a ~/read, a ~/bin. And a few others. I have my $PATH variable with the ~/bin directory tacked on the end.

And a few other things.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
For wholesale pirated mp3 organizing:

alias CleanMp3s="sh $HOME/scripts/cleanmp3s.sh"

cleanmp3s.sh is:
rename 'y/A-Z/a-z/' *mp3
/bin/ls -1 *mp3 | while read i
do
..id3v2 -D "$i" > /dev/null
..chown death.death "$i"
..chmod 644 "$i"

..echo -n "done with: "
../bin/ls -l "$i"
done
.. which lowercases all *.mp3 files, strips all id3 tags, and makes sure permissions are ok.

alias Lower="rename 'y/A-Z/a-z/'"

fairly obvious.

alias Bitrate="mp3info -p '%f\n %r\n\n' -r a"

prints out the bitrate of the arguments, for example "Bitrate *" will show bitrates of all files in a dir.

alias Track="python $HOME/py/addtrack.py"

this is a kind of complex script, but basically if i have files which are missing track numbers, this will add them. For example if I have "artist - a.mp3" and "artist - b.mp3", then I do "Track artist\ -\ a.mp3 artist\ -\ b.mp3" and it'll rename them to "artist - 01 - a.mp3" and "artist - 02 - b.mp3".

alias Id3="python $HOME/py/id3tag.py"

id3tag.py is another somewhat complex script which takes a directory as an argument, looks at the mp3s in it, and then, based on my standard naming format ("artist - 01 - song.mp3"), puts the right id3 tags in the mp3.

alias BurnAlbum="sh $HOME/scripts/burnalbum.sh"

burnalbum.sh is:

if ls *.mp3 >/dev/null 2>&1; then :; else
....echo "no mp3s here"
....exit
fi

`which ls` -1 ./*.mp3 | while read i
do
....mpg321 -w "$i.burn-temp.wav" "$i"
done

printf "insert cd and press enter "
read

sudo cdrecord -v driveropts=burnfree -pad -dao -audio *.burn-temp.wav

printf "hit enter to delete the .wav files"
read

rm -f *.burn-temp.wav

... basically just burns the mp3s in a directory. they're automatically in the right order since the track # is the first unique thing in the filenames.

alias MpdReset="mpc clear && mpc listall | mpc add - && mpc random 1 && mpc repeat 1 && mpc play"

for mpd, what it does is somewhat obvious

alias Thlog='ssh fw "sh /var/www/thlog/add.sh"'

ssh's to my server and runs a little script there to add an entry to my blog-like-thingie, which is just a static html page updated by this script.

I also have backup scripts on each machine which each night tar up my home dir and whatnot and send the tarballs to each other (so a drive failure in either machine wouldn't be catastrophic, yet i don't need to be munging with cds or tapes or whatever all the time to back up -- i do backup to cd every so often, though)

I don't like that starting X with "startx" means that X will exit whenever your magic last program in .xinitrc exits , and I don't like display managers, so I have a startx script which I use to start X: http://incise.org/files/etc/startx.txt

Oh yeah, the rename command that (sometimes) comes with perl is great for mass file renames. Basically you tell it a regexp and what files to work on, and it applies that regexp to the file names. Simple, but sooooo useful.

Firefox being one of the few gui apps I use -- and the one I start/restart/whatever the most often -- I have a small alias for starting it:

alias ff="firefox & exit"

that's kind of silly, but whatever. Instead of having some toolbar with buttons on it (like a taskbar or something), or icons on my desktop, etc., I just hit Ctrl+Alt+X for an xterm, then type ff and the term goes away and here comes firefox. Probably not impressive for someone who likes lots of gui stuff, but gui apps are the exception for me, and so that's pretty convenient for me -- much nicer than a toolbar robbing 50000 pixels of my screen space 24/7.

alias weather="sh $HOME/scripts/weather.sh"

weather.sh is:

( lynx --dump "http://www.w3.weather.com/weather/local/52806" | grep -A 1 -B 1 "Feels Like" | sed -e "s/Feels Like//" | sed -e "s/\[.*\]//" | sed -e "s/[^a-zA-Z0-9]//g" ) 2>/dev/null

replace my zip code with yours and run it :) (i need to fix the fact that it strips spaces out of the "conditions" text)

I have other crap but this is the stuff I use pretty regularly.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: n0cmonkey
Originally posted by: screw3d
/Leaves thread

Don't know what you guys are talking about :eek: but it sounds cool and I should learn Linux :(

It's only cool if you type well. :p

I suggest gtypist for learning. Once you can get around 20 or so words per minute with out much errrors and with out having to look at the keyboard much then it makes life much simplier.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: drag
Originally posted by: n0cmonkey
Originally posted by: screw3d
/Leaves thread

Don't know what you guys are talking about :eek: but it sounds cool and I should learn Linux :(

It's only cool if you type well. :p

I suggest gtypist for learning. Once you can get around 20 or so words per minute with out much errrors and with out having to look at the keyboard much then it makes life much simplier.

I recommend IRC. Proper typing is ok and all, but never felt comfortable. I do quite well with my messed up typing. Unless someone is watching. Then I'm horrible. :p
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: n0cmonkey I do quite well with my messed up typing. Unless someone is watching. Then I'm horrible. :p

Hahaha, me too. Although I don't type messed up, other than using my left thumb for space (supposedly the "wrong" thumb).
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
just as long as you know the layout.

I gave up on hunt and peck, although it was fast, when doing school work on the computer.

Look at the book... look at the keyboard. tap tap tap.
look at the screen, look at the keyboard, tap tap tap.
look at the book, look at the keyboard, tap, look at the screen...
backspace backspace backspace X10
get lost, start over...

Was a pain in the butt.

Now I just go look at book, look at screen, look at book, look at screen, backspace backspace X10. look at the book, look at the screen.

Or when using online docs, you just look back and forth between two windows. while typing continuously.

Bash would be a pain in the arse if every two seconds you'd have to scan the keyboard to find the | key.

(my bad typing habit is that I only use my right shift key)

(plus proper typing saves wrists... as long as you can keep your hand movement to a minimum and only type by moving your fingers it helps a lot to aviod bad stuff.)
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: drag
just as long as you know the layout.

I gave up on hunt and peck, although it was fast, when doing school work on the computer.

Look at the book... look at the keyboard. tap tap tap.
look at the screen, look at the keyboard, tap tap tap.
look at the book, look at the keyboard, tap, look at the screen...
backspace backspace backspace X10
get lost, start over...

Was a pain in the butt.

Now I just go look at book, look at screen, look at book, look at screen, backspace backspace X10. look at the book, look at the screen.

Or when using online docs, you just look back and forth between two windows. while typing continuously.

Bash would be a pain in the arse if every two seconds you'd have to scan the keyboard to find the | key.

(my bad typing habit is that I only use my right shift key)

(plus proper typing saves wrists... as long as you can keep your hand movement to a minimum and only type by moving your fingers it helps a lot to aviod bad stuff.)

I only use the right shift key. If I try to use the left one I sometimes hit the caps lock button.

As far as having to find the | key, I have like 5 different keyboard (work, sun, ergonomic, CHEAP, laptop), and they're all different enough to keep me looking occassionally. :p

And I have trouble typing in the dark. I don't have to look at the keyboard often (usually just when I'm first getting there, or mentally lost while typing, or hitting a symbol key like # or $), but typing in the dark gets me.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: BingBongWongFooey
Originally posted by: n0cmonkey I do quite well with my messed up typing. Unless someone is watching. Then I'm horrible. :p

Hahaha, me too. Although I don't type messed up, other than using my left thumb for space (supposedly the "wrong" thumb).

I have a 3 finger style. Index, middle, and thumb of each hand (although my left thumb gets very little use). Pinky for tab, ~, shift, enter, etc. :confused:
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Originally posted by: BingBongWongFooey
Originally posted by: n0cmonkey I do quite well with my messed up typing. Unless someone is watching. Then I'm horrible. :p

Hahaha, me too. Although I don't type messed up, other than using my left thumb for space (supposedly the "wrong" thumb).

Better than me I suppose.
I use my right index finger to hit the spacebar pretty hard, and the right middlefinger to hit enter even harder.
But then, I hit pretty much every button pretty hard compared to just about everyone, it just feels good to "type hard", and lets out some anger in the process ;)

Of course, this means that I need sturdy keyboards, luckily Keytronic keyboards are sturdy enough, and all around excellent, so that's not a problem :)
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Hm, I type pretty normally other than the space thumb thing. The only other thing I can think of is that I don't hit escape with my pinky; I hit it with usually my middle finger or sometimes my 3rd finger. Pinky is so damn short, it just seems like more reaching than necessary.
 

pitupepito2000

Golden Member
Aug 2, 2002
1,181
0
0
Originally posted by: cleverhandle
For ls stuff, I alias ls to "ls --color=auto" and also set the following function:

lsl{ \ls --color=yes -lA $@ | less -RFX}

I'll leave it to interested readers to work out the details of that.

But that being said, and having read the earlier post, I don't really get what you mean by "browsing". I mean, certainly Nautilus or any other FM will let you look through directories, so I assume you mean more than that. Could you maybe list some tasks that you're trying to accomplish? I don't find myself using a terminal very often, apart from ssh'ing into my servers to check them out. Nautilus works fine for me as far as clicky-opening typical files, and other stuff I'll write a script for. Zenity is very handy in this regard.

What I was trying to find out by posting this topic, is what aliases, scripts or gui-less programs did people use for file browsing. I'm sure there are people like me who rarely use a file manager/browser such as konqueror, ROX, nautilus, etc.
 

pitupepito2000

Golden Member
Aug 2, 2002
1,181
0
0
Originally posted by: n0cmonkey
Originally posted by: Sunner
Nothing special really, I pretty much just type&go.
I hate colors, and I hate rm/mv/etc -i, unfortunately Redhat(which we use on most of out boxes at work) creates those aliases automatically.

Ew. You can fix that though. :evil:

I like the -i flag. It comes in handy, but I like it as an option. ;)

I also hate find, it's a godawful command.

What's wrong with find? :confused:

why not set the "-i" option as default in your bashrc file?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: pitupepito2000
Originally posted by: n0cmonkey
Originally posted by: Sunner
Nothing special really, I pretty much just type&go.
I hate colors, and I hate rm/mv/etc -i, unfortunately Redhat(which we use on most of out boxes at work) creates those aliases automatically.

Ew. You can fix that though. :evil:

I like the -i flag. It comes in handy, but I like it as an option. ;)

I also hate find, it's a godawful command.

What's wrong with find? :confused:

why not set the "-i" option as default in your bashrc file?

Because then I'd have to use bash. :p

I don't want -i as default. I just want it to be there for the 2 times I use it every month. ;)
 

pitupepito2000

Golden Member
Aug 2, 2002
1,181
0
0
n0cmonkey, I personally find that the "-i" option has saved my a** many times, that I would have overwritten files that I didn't want to overwrite. I alsmost see it as a must, otherwise whithout it the changes that you made by mistake are permanent :(