I'm constantly losing track of where I'm at when using the command line (which I use heavily). I end up typing ls -al and pwd all the time and was wondering if there exists a utility that will basically show in a some kind of frame the current working directory and all files in it. It doesn't need to be GUI, just some sort of real-time "here's where you are and what's in the directory".
I am pretty sure you can configure your command prompt to show which directory you are currently in. I am not sure what to tell you about listing the files : \
Are you using Linux with the bash shell? If so, then you need to read The Bash Prompt How-To. Printing the working directory in your prompt is pretty easy:
PS1="\w $ "
If you want to get wacky with it, you can make yourself a shell script like this:
#!/bin/bash
ls -l | tail -n 5
name it 'myscript', put it in your PATH, and source it in your bash prompt:
PS1="\$(myscript) \n\w $ "
You'll now get the last five entries of an 'ls -l' listing and the current working directory in your prompt:
The number is the bash history command number. It increments every time you run a command. So if you run a complex command (let's say it has history number 123), and a few prompts later you want to run the same command, you can just run:
!123
and the shell will execute the command with history number 123. You can combine it with the 'history' command to do tricks like:
┌[mcviking]─[@dragonfly]─[1382]────────[~]
└> history | grep find
701 cd programs/perl/findpix/
703 less findpix-gconftool.pl
1380 history | grep find
1382 history | grep find
┌[mcviking]─[@dragonfly]─[1383]────────[~]
└> !701
cd programs/perl/findpix/
┌[mcviking]─[@dragonfly]─[1384]────────[~/programs/perl/findpix]
└>
Double tab, theres everything in your directory(or the directory you are typing).
As far as PWD.... just type in PWD. You don't need a new tool, you need to use what tools you already have.
Yeah, he already said he uses ls -al and pwd a lot. His point is he doesn't want to have to type these commands constantly to remind himself where he is. Hitting tab-tab all the time will give you RSI.
The number is the bash history command number. It increments every time you run a command. So if you run a complex command (let's say it has history number 123), and a few prompts later you want to run the same command, you can just run:
!123
and the shell will execute the command with history number 123. You can combine it with the 'history' command to do tricks like:
┌[mcviking]─[@dragonfly]─[1382]────────[~]
└> history | grep find
701 cd programs/perl/findpix/
703 less findpix-gconftool.pl
1380 history | grep find
1382 history | grep find
┌[mcviking]─[@dragonfly]─[1383]────────[~]
└> !701
cd programs/perl/findpix/
┌[mcviking]─[@dragonfly]─[1384]────────[~/programs/perl/findpix]
└>
Occasionally when I'm using the up and down arrows to look through previous commands, I'll get 6 letters or so stuck at the beginning of the prompt, like this:
I had a missing escape sequence somewhere in that mess, and it was causing line wrap problems with long commands. The bad news is that I never bothered debugging it. The good news is that I made a new, improved prompt with this amazing tool. The new hotness looks like this:
-[\[\033[0m\]\[\033[0;31m\]\u\[\033[0m\]\[\033[1;37m\]@\[\033[0m\]\[\033[1;33m\]\h\[\033[0m\]\[\033[1;37m\]]-[\[\033[0m\]\[\033[0;32m\]${PWD}\[\033[0m\]\[\033[1;37m\]]-[\[\033[0m\]\[\033[0;36m\]$(ls --si -s | head -1 | awk '{print $2}')\[\033[0m\]\[\033[1;37m\]]-[\[\033[0m\]\[\033[1;35m\]$(temp=$(cat /proc/uptime) && upSec=${temp%%.*} ; let secs=$((${upSec}%60)) ; let mins=$((${upSec}/60%60)) ; let hours=$((${upSec}/3600%24)) ; let days=$((${upSec}/86400)) ; if [ ${days} -ne 0 ]; then echo -n ${days}d; fi ; echo -n ${hours}h${mins}m)\[\033[0m\]\[\033[1;37m\]]-\n-[\[\033[0m\]\[\033[1;34m\]\!\[\033[0m\]\[\033[1;37m\]]-> \[\033[0;0m\]
The downside is that it takes it a moment to run the command that shows disk usage. But it would be easy enough to remove that.
Posts
Double tab, theres everything in your directory(or the directory you are typing).
As far as PWD.... just type in PWD. You don't need a new tool, you need to use what tools you already have.
If you want to get wacky with it, you can make yourself a shell script like this:
name it 'myscript', put it in your PATH, and source it in your bash prompt:
You'll now get the last five entries of an 'ls -l' listing and the current working directory in your prompt:
You can also have no end of fun with colors and the like. My $PS1 these days looks like this:
Which only appears insane until you try it. There are some crazy clever example prompts at the end of the how-to. Have fun!
Edit: nope, guess not
and the shell will execute the command with history number 123. You can combine it with the 'history' command to do tricks like:
Yeah, he already said he uses ls -al and pwd a lot. His point is he doesn't want to have to type these commands constantly to remind himself where he is. Hitting tab-tab all the time will give you RSI.
Thanks for the condescension though.
Occasionally when I'm using the up and down arrows to look through previous commands, I'll get 6 letters or so stuck at the beginning of the prompt, like this:
cd sitwget http://...etc
where the cd sit is totally ignored, but a bit confusing. Any idea what might be the cause?
The downside is that it takes it a moment to run the command that shows disk usage. But it would be easy enough to remove that.