Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Okay, this is a last attempt to see if I can salvage something I accidentally did.

I accidentally did "command > ~/.profile" instead of "command >> ~/.profile" on my computer.

I didn't have it version controlled (never happening again), and since the .profile wasn't open in an editor at the time, I don't have an existing version in any backup file or Vim buffer.

The only thing I can possibly think of at this point is that I still have a terminal session open running the lines that were in the ~/.profile file prior to my mistake above. My question is: Is there any way to get the currently executed source?

Maybe to be more explicit and generic, if I run

source ~/.profile

Is there any way to see what got executed in that terminal session outside of looking at the file that was sourced?

Lesson learned though, version ALL your dotfiles.

Thanks in advance.

-Hassan

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Not that i know of, but depending on what was in there, you can get a good portion of back in the terminal that is still open:

This will get your your prompt definition

$ echo $PS1

This will get you all of your shell variables and defined functions. it may be a LOT of stuff because, in Ubuntu for instance, there are all sorts of other macros for completion and whatnot defined, but you can extract what was yours.

$ set

This will give you your aliases

$ alias

These won't give you any logic that was in your .profile that helped decide how or why to define the things above, but they may get you much of what you need.

share|improve this answer
    
This was really helpful. A large chunk of what I was hoping to retain is in some combination of the three. Thanks. –  Hassan Shahid Sep 18 '13 at 19:19
    
glad to help :) –  jerm Sep 28 '13 at 16:57
add comment

You could try the history command in the session that ran the script to get a list of commands that have been recently executed.

share|improve this answer
    
as far as I can see or tell; history doesn't track anything that was run during terminal session startup/initialization. Thanks for trying to help though. –  Hassan Shahid Sep 18 '13 at 20:17
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.