Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On my c shell, I use the alias p ls -lt; pwd to speed up things while switching directories and getting their listings.

Things could be much easier if I could somehow divide the space I have on my console in two parts such that the prompt is in the lower part and the top part always shows the listing of the current directory (the directory which I am using in the second part).

alt text

The upper part needs to be dynamic in the sense that whenever I switch directories using the prompt in the lower part, It should give the listing of the current directory in the upper half.

Is there any way (script?) that lets me do something like this?

share|improve this question
add comment

3 Answers

Midnight Commander will sort of do what you want. It gives a two-pane file navigator at the top and a shell-like prompt at the bottom. I would recommend setting the Option > Configuration > Pause after run > Always so when you type a command the result is shown before the file navigator screen is redisplayed. Unfortunately it doesn't have a larger shell window for the bottom half like you want.

share|improve this answer
add comment

If you want the upper part to appear all the time, you can use screen or tmux. While this is not their most often-used feature, both of these programs support splitting a window in two. So you can run your interactive shell in the lower window, and use an alias for cd that goes and displays things in the upper window. An easy way to do that last bit is to create a named pipe (mkfifo ~/.window-pipe-$PPID where $PPID is the process id of the screen or tmux process) and run a script like this in the upper window (sh syntax, adapt to csh if you must):

while read -r dir; do
  printf '\033[?9l%s' "$dir"
  cd "$dir"
  ls -lt
done <~/.window-pipe-$PPID

You might want to truncate the output of ls to fit in the window, as it is probably more useful to keep the first few lines than the last few lines if it doesn't fit. In the bottom window, the cd replacement would be a function like (again, I'm using sh syntax):

cd () {
  builtin cd "$@" && pwd >~/.window-pipe-$PPID
}
share|improve this answer
add comment

Moving to a command-line file manager would probably be a much easier and cleaner solution than concocting something custom, as the idea has already been implemented. There is a myriad of them out where which are all highly configurable, such as CLEX:

alt text

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.