Can I recover my .bash_profile from an open Terminal tab?Issues with .bash_profile and terminal commandsHow...

Best species to breed to intelligence

Improving Sati-Sampajañña (situative wisdom)

is it permitted to swallow spit on a fast day?

Are there variations of the regular runtimes of the Big-O-Notation?

What can cause an unfrozen indoor copper drain pipe to crack?

What was the plan for an abort of the Enola Gay's mission to drop the atomic bomb?

Why does increasing the sampling rate make implementing an anti-aliasing filter easier?

What does formal training in a field mean?

Should I pay on student loans in deferment or continue to snowball other debts?

Does the 500 feet falling cap apply per fall, or per turn?

date -d 'previous Monday" to display the preceding Monday

Why do Thanos' punches not kill Captain America or at least cause vital wounds?

My perfect evil overlord plan... or is it?

Watching the game, having a puzzle

How are one-time password generators like Google Authenticator different from having two passwords?

Removing all characters except digits from clipboard

How to get the IP of a user who executed a command?

No such column 'DeveloperName' on entity 'RecordType' after Summer '19 release on sandbox

How do I compare the result of "1d20+x, with advantage" to "1d20+y, without advantage", assuming x < y?

What do "KAL." and "A.S." stand for in this inscription?

Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019

Which other programming languages apart from Python and predecessor are out there using indentation to define code blocks?

Is this state of Earth possible, after humans left for a million years?

Translation of the latin word 'sit' in Thomas Aquinas' works



Can I recover my .bash_profile from an open Terminal tab?


Issues with .bash_profile and terminal commandsHow to send all output to a pager by default?Suse 11 vs. Suse 10 difference impacting terminal colors?Why does tmux mess up my Ubuntu login, though it works ok once logged in for new windows?automatic line on every terminal tab openHow do I run a command in a new terminal window in the same process as the original?Heredocument error I can't understand (“delimited by end of file”)How to change/fix the v command in less using a shell profile?Mac terminal cannot not execute .bash_profileAvoid sourcing scripts multiple times






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







4















I'm actually using a Macbook Pro, and am quite new to non-Windows OS' (I know, for shame!), and I've made the mistake of overwriting my bash profile, instead of appending to it...



What I do have is a couple of open tabs in the Terminal, and am hoping that there might be a way of recovering my .bash_profile from this (or any way really).










share|improve this question

























  • Restore from backup.

    – Cyrus
    Apr 3 '15 at 19:47











  • Unless it has set -x at the beginning, so that it echoes all the statements as it's executing them, where in the terminal output do you expect to copy it from? And even that wouldn't have the commands from if and else clauses that don't get executed.

    – Barmar
    Apr 3 '15 at 19:53











  • Don't you have Time Machine enabled for backups?

    – Barmar
    Apr 3 '15 at 19:53











  • I don't have Timemachine switched on unfortunately, unless there is another way to recover?

    – Fifer Sheep
    Apr 3 '15 at 19:54






  • 1





    If you've not edited it previously perhaps you can create a new user account and copy it from there. Or from your equivalent of /etc/skel

    – roaima
    Apr 3 '15 at 22:57


















4















I'm actually using a Macbook Pro, and am quite new to non-Windows OS' (I know, for shame!), and I've made the mistake of overwriting my bash profile, instead of appending to it...



What I do have is a couple of open tabs in the Terminal, and am hoping that there might be a way of recovering my .bash_profile from this (or any way really).










share|improve this question

























  • Restore from backup.

    – Cyrus
    Apr 3 '15 at 19:47











  • Unless it has set -x at the beginning, so that it echoes all the statements as it's executing them, where in the terminal output do you expect to copy it from? And even that wouldn't have the commands from if and else clauses that don't get executed.

    – Barmar
    Apr 3 '15 at 19:53











  • Don't you have Time Machine enabled for backups?

    – Barmar
    Apr 3 '15 at 19:53











  • I don't have Timemachine switched on unfortunately, unless there is another way to recover?

    – Fifer Sheep
    Apr 3 '15 at 19:54






  • 1





    If you've not edited it previously perhaps you can create a new user account and copy it from there. Or from your equivalent of /etc/skel

    – roaima
    Apr 3 '15 at 22:57














4












4








4


1






I'm actually using a Macbook Pro, and am quite new to non-Windows OS' (I know, for shame!), and I've made the mistake of overwriting my bash profile, instead of appending to it...



What I do have is a couple of open tabs in the Terminal, and am hoping that there might be a way of recovering my .bash_profile from this (or any way really).










share|improve this question
















I'm actually using a Macbook Pro, and am quite new to non-Windows OS' (I know, for shame!), and I've made the mistake of overwriting my bash profile, instead of appending to it...



What I do have is a couple of open tabs in the Terminal, and am hoping that there might be a way of recovering my .bash_profile from this (or any way really).







bash command-line terminal bashrc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









Rui F Ribeiro

42.7k1486146




42.7k1486146










asked Apr 3 '15 at 19:45









Fifer SheepFifer Sheep

12315




12315













  • Restore from backup.

    – Cyrus
    Apr 3 '15 at 19:47











  • Unless it has set -x at the beginning, so that it echoes all the statements as it's executing them, where in the terminal output do you expect to copy it from? And even that wouldn't have the commands from if and else clauses that don't get executed.

    – Barmar
    Apr 3 '15 at 19:53











  • Don't you have Time Machine enabled for backups?

    – Barmar
    Apr 3 '15 at 19:53











  • I don't have Timemachine switched on unfortunately, unless there is another way to recover?

    – Fifer Sheep
    Apr 3 '15 at 19:54






  • 1





    If you've not edited it previously perhaps you can create a new user account and copy it from there. Or from your equivalent of /etc/skel

    – roaima
    Apr 3 '15 at 22:57



















  • Restore from backup.

    – Cyrus
    Apr 3 '15 at 19:47











  • Unless it has set -x at the beginning, so that it echoes all the statements as it's executing them, where in the terminal output do you expect to copy it from? And even that wouldn't have the commands from if and else clauses that don't get executed.

    – Barmar
    Apr 3 '15 at 19:53











  • Don't you have Time Machine enabled for backups?

    – Barmar
    Apr 3 '15 at 19:53











  • I don't have Timemachine switched on unfortunately, unless there is another way to recover?

    – Fifer Sheep
    Apr 3 '15 at 19:54






  • 1





    If you've not edited it previously perhaps you can create a new user account and copy it from there. Or from your equivalent of /etc/skel

    – roaima
    Apr 3 '15 at 22:57

















Restore from backup.

– Cyrus
Apr 3 '15 at 19:47





Restore from backup.

– Cyrus
Apr 3 '15 at 19:47













Unless it has set -x at the beginning, so that it echoes all the statements as it's executing them, where in the terminal output do you expect to copy it from? And even that wouldn't have the commands from if and else clauses that don't get executed.

– Barmar
Apr 3 '15 at 19:53





Unless it has set -x at the beginning, so that it echoes all the statements as it's executing them, where in the terminal output do you expect to copy it from? And even that wouldn't have the commands from if and else clauses that don't get executed.

– Barmar
Apr 3 '15 at 19:53













Don't you have Time Machine enabled for backups?

– Barmar
Apr 3 '15 at 19:53





Don't you have Time Machine enabled for backups?

– Barmar
Apr 3 '15 at 19:53













I don't have Timemachine switched on unfortunately, unless there is another way to recover?

– Fifer Sheep
Apr 3 '15 at 19:54





I don't have Timemachine switched on unfortunately, unless there is another way to recover?

– Fifer Sheep
Apr 3 '15 at 19:54




1




1





If you've not edited it previously perhaps you can create a new user account and copy it from there. Or from your equivalent of /etc/skel

– roaima
Apr 3 '15 at 22:57





If you've not edited it previously perhaps you can create a new user account and copy it from there. Or from your equivalent of /etc/skel

– roaima
Apr 3 '15 at 22:57










4 Answers
4






active

oldest

votes


















5














If your terminal is still open, type env: it will display all your environment variables. If it's a fresh install or if you never made any change, the most important variables are PATH (this one always exist) and LD_LIBRARY_PATH (may not exists, I'm not used to osx).



For instance:



$ env
...
PATH=/usr/bin:/bin:/home/user/bin:/sbin
...


It's also a common thing to source .bashrc in that file.



Then you can edit your .bash_profile to add a line like this:



# Source your .bashrc
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi

# Export the interesting env variables you
# displayed from env command previously
export PATH=/usr/bin:/bin:/home/user/bin:/sbin


It's not a real solution since it's not a real "backup", but keep in mind that as long your terminal is open, you can know your environment variables, and main purpose of .bash_profile is to set those variables.



Also, you may have some aliases: in your opened terminal, type alias to display all the defined aliases. You can copy and paste the ouput as-is in your .bash_profile. (obviously, if those aliases are available in your .bashrc you don't need to define them in your .bash_profile since you source the .bashrc previously.)






share|improve this answer
























  • Good call. Although this does not do what the OP asked for, it may provide enough info for him to reconstruct his file.

    – Warren Young
    Apr 4 '15 at 0:12











  • Hero! Using a combination of env, alias and type function_name for each function - I was able reconstruct most of the profile. At least that which I care most about anyway.

    – Fifer Sheep
    Apr 4 '15 at 1:42





















2














You seem to be implicitly asking if there is a place in RAM where the contents of this file are stored. The answer is, "no." The file is simply read and executed during shell startup, then discarded. No Unix shell needs continuous access to its startup script(s).



Some of the file's contents are still retrievable, per apaul's answer.



There is a tiny chance that there are fragments of the file itself in freed RAM that hasn't yet been reallocated or returned to the OS, but it's probably not worth your time to try to construct a program to dump the contents of RAM to a disk file and then plow through it to try and find your file contents.



Take the lessons you've been given and learn from them:




  1. Think twice before pressing Enter on a command involving > instead of >>, just as you have hopefully learned to be careful with rm commands.



  2. Set up Time Machine, soonest.



    Once upon a time, not having a recent backup was a sad but too-common tale. Now it's unforgivable. Apple has gone and made it as easy as you could reasonably ask.








share|improve this answer


























  • Yep, it's exactly what I was asking. I had a feeling that this was the case - and have most certainly learned some valuable lessons! Thank you for confirming, and I will mark this as the answer.

    – Fifer Sheep
    Apr 3 '15 at 21:28











  • I'm somewhat ashamed to admit Richard that I'm studying Software Engineering, and know git very well :(

    – Fifer Sheep
    Apr 3 '15 at 22:06



















2














This just happened to me and I recovered as follows...



Defined vars and functions:



$ declare > definitions.bash.txt


Aliases:



$ alias > aliases.bash.txt





share|improve this answer































    0














    A stupid script did that to my bashrc so I ran the following to retrieve most of my file.



    # Retrieve functions definitions
    $ declare > .bashrc.new
    # Retrieve aliases
    $ alias >> .bashrc.new
    # Retrieve env
    $ echo "export $(env | grep ^PATH=)" >> .bashrc.new


    Here, most of your .bashrc is almost reconstructed. Now you just need to make small adjustements to ensure it matches your best practices. ;)



    A cool command to find the defintion of your custom functions: type my_function >> .bashrc.new.



    Also, make sure to review your env return value to include what you think is important into the newly created file.






    share|improve this answer
























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "106"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f194278%2fcan-i-recover-my-bash-profile-from-an-open-terminal-tab%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      5














      If your terminal is still open, type env: it will display all your environment variables. If it's a fresh install or if you never made any change, the most important variables are PATH (this one always exist) and LD_LIBRARY_PATH (may not exists, I'm not used to osx).



      For instance:



      $ env
      ...
      PATH=/usr/bin:/bin:/home/user/bin:/sbin
      ...


      It's also a common thing to source .bashrc in that file.



      Then you can edit your .bash_profile to add a line like this:



      # Source your .bashrc
      if [ -f ~/.bashrc ]; then
      source ~/.bashrc
      fi

      # Export the interesting env variables you
      # displayed from env command previously
      export PATH=/usr/bin:/bin:/home/user/bin:/sbin


      It's not a real solution since it's not a real "backup", but keep in mind that as long your terminal is open, you can know your environment variables, and main purpose of .bash_profile is to set those variables.



      Also, you may have some aliases: in your opened terminal, type alias to display all the defined aliases. You can copy and paste the ouput as-is in your .bash_profile. (obviously, if those aliases are available in your .bashrc you don't need to define them in your .bash_profile since you source the .bashrc previously.)






      share|improve this answer
























      • Good call. Although this does not do what the OP asked for, it may provide enough info for him to reconstruct his file.

        – Warren Young
        Apr 4 '15 at 0:12











      • Hero! Using a combination of env, alias and type function_name for each function - I was able reconstruct most of the profile. At least that which I care most about anyway.

        – Fifer Sheep
        Apr 4 '15 at 1:42


















      5














      If your terminal is still open, type env: it will display all your environment variables. If it's a fresh install or if you never made any change, the most important variables are PATH (this one always exist) and LD_LIBRARY_PATH (may not exists, I'm not used to osx).



      For instance:



      $ env
      ...
      PATH=/usr/bin:/bin:/home/user/bin:/sbin
      ...


      It's also a common thing to source .bashrc in that file.



      Then you can edit your .bash_profile to add a line like this:



      # Source your .bashrc
      if [ -f ~/.bashrc ]; then
      source ~/.bashrc
      fi

      # Export the interesting env variables you
      # displayed from env command previously
      export PATH=/usr/bin:/bin:/home/user/bin:/sbin


      It's not a real solution since it's not a real "backup", but keep in mind that as long your terminal is open, you can know your environment variables, and main purpose of .bash_profile is to set those variables.



      Also, you may have some aliases: in your opened terminal, type alias to display all the defined aliases. You can copy and paste the ouput as-is in your .bash_profile. (obviously, if those aliases are available in your .bashrc you don't need to define them in your .bash_profile since you source the .bashrc previously.)






      share|improve this answer
























      • Good call. Although this does not do what the OP asked for, it may provide enough info for him to reconstruct his file.

        – Warren Young
        Apr 4 '15 at 0:12











      • Hero! Using a combination of env, alias and type function_name for each function - I was able reconstruct most of the profile. At least that which I care most about anyway.

        – Fifer Sheep
        Apr 4 '15 at 1:42
















      5












      5








      5







      If your terminal is still open, type env: it will display all your environment variables. If it's a fresh install or if you never made any change, the most important variables are PATH (this one always exist) and LD_LIBRARY_PATH (may not exists, I'm not used to osx).



      For instance:



      $ env
      ...
      PATH=/usr/bin:/bin:/home/user/bin:/sbin
      ...


      It's also a common thing to source .bashrc in that file.



      Then you can edit your .bash_profile to add a line like this:



      # Source your .bashrc
      if [ -f ~/.bashrc ]; then
      source ~/.bashrc
      fi

      # Export the interesting env variables you
      # displayed from env command previously
      export PATH=/usr/bin:/bin:/home/user/bin:/sbin


      It's not a real solution since it's not a real "backup", but keep in mind that as long your terminal is open, you can know your environment variables, and main purpose of .bash_profile is to set those variables.



      Also, you may have some aliases: in your opened terminal, type alias to display all the defined aliases. You can copy and paste the ouput as-is in your .bash_profile. (obviously, if those aliases are available in your .bashrc you don't need to define them in your .bash_profile since you source the .bashrc previously.)






      share|improve this answer













      If your terminal is still open, type env: it will display all your environment variables. If it's a fresh install or if you never made any change, the most important variables are PATH (this one always exist) and LD_LIBRARY_PATH (may not exists, I'm not used to osx).



      For instance:



      $ env
      ...
      PATH=/usr/bin:/bin:/home/user/bin:/sbin
      ...


      It's also a common thing to source .bashrc in that file.



      Then you can edit your .bash_profile to add a line like this:



      # Source your .bashrc
      if [ -f ~/.bashrc ]; then
      source ~/.bashrc
      fi

      # Export the interesting env variables you
      # displayed from env command previously
      export PATH=/usr/bin:/bin:/home/user/bin:/sbin


      It's not a real solution since it's not a real "backup", but keep in mind that as long your terminal is open, you can know your environment variables, and main purpose of .bash_profile is to set those variables.



      Also, you may have some aliases: in your opened terminal, type alias to display all the defined aliases. You can copy and paste the ouput as-is in your .bash_profile. (obviously, if those aliases are available in your .bashrc you don't need to define them in your .bash_profile since you source the .bashrc previously.)







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Apr 3 '15 at 21:32









      apaulapaul

      2,5401913




      2,5401913













      • Good call. Although this does not do what the OP asked for, it may provide enough info for him to reconstruct his file.

        – Warren Young
        Apr 4 '15 at 0:12











      • Hero! Using a combination of env, alias and type function_name for each function - I was able reconstruct most of the profile. At least that which I care most about anyway.

        – Fifer Sheep
        Apr 4 '15 at 1:42





















      • Good call. Although this does not do what the OP asked for, it may provide enough info for him to reconstruct his file.

        – Warren Young
        Apr 4 '15 at 0:12











      • Hero! Using a combination of env, alias and type function_name for each function - I was able reconstruct most of the profile. At least that which I care most about anyway.

        – Fifer Sheep
        Apr 4 '15 at 1:42



















      Good call. Although this does not do what the OP asked for, it may provide enough info for him to reconstruct his file.

      – Warren Young
      Apr 4 '15 at 0:12





      Good call. Although this does not do what the OP asked for, it may provide enough info for him to reconstruct his file.

      – Warren Young
      Apr 4 '15 at 0:12













      Hero! Using a combination of env, alias and type function_name for each function - I was able reconstruct most of the profile. At least that which I care most about anyway.

      – Fifer Sheep
      Apr 4 '15 at 1:42







      Hero! Using a combination of env, alias and type function_name for each function - I was able reconstruct most of the profile. At least that which I care most about anyway.

      – Fifer Sheep
      Apr 4 '15 at 1:42















      2














      You seem to be implicitly asking if there is a place in RAM where the contents of this file are stored. The answer is, "no." The file is simply read and executed during shell startup, then discarded. No Unix shell needs continuous access to its startup script(s).



      Some of the file's contents are still retrievable, per apaul's answer.



      There is a tiny chance that there are fragments of the file itself in freed RAM that hasn't yet been reallocated or returned to the OS, but it's probably not worth your time to try to construct a program to dump the contents of RAM to a disk file and then plow through it to try and find your file contents.



      Take the lessons you've been given and learn from them:




      1. Think twice before pressing Enter on a command involving > instead of >>, just as you have hopefully learned to be careful with rm commands.



      2. Set up Time Machine, soonest.



        Once upon a time, not having a recent backup was a sad but too-common tale. Now it's unforgivable. Apple has gone and made it as easy as you could reasonably ask.








      share|improve this answer


























      • Yep, it's exactly what I was asking. I had a feeling that this was the case - and have most certainly learned some valuable lessons! Thank you for confirming, and I will mark this as the answer.

        – Fifer Sheep
        Apr 3 '15 at 21:28











      • I'm somewhat ashamed to admit Richard that I'm studying Software Engineering, and know git very well :(

        – Fifer Sheep
        Apr 3 '15 at 22:06
















      2














      You seem to be implicitly asking if there is a place in RAM where the contents of this file are stored. The answer is, "no." The file is simply read and executed during shell startup, then discarded. No Unix shell needs continuous access to its startup script(s).



      Some of the file's contents are still retrievable, per apaul's answer.



      There is a tiny chance that there are fragments of the file itself in freed RAM that hasn't yet been reallocated or returned to the OS, but it's probably not worth your time to try to construct a program to dump the contents of RAM to a disk file and then plow through it to try and find your file contents.



      Take the lessons you've been given and learn from them:




      1. Think twice before pressing Enter on a command involving > instead of >>, just as you have hopefully learned to be careful with rm commands.



      2. Set up Time Machine, soonest.



        Once upon a time, not having a recent backup was a sad but too-common tale. Now it's unforgivable. Apple has gone and made it as easy as you could reasonably ask.








      share|improve this answer


























      • Yep, it's exactly what I was asking. I had a feeling that this was the case - and have most certainly learned some valuable lessons! Thank you for confirming, and I will mark this as the answer.

        – Fifer Sheep
        Apr 3 '15 at 21:28











      • I'm somewhat ashamed to admit Richard that I'm studying Software Engineering, and know git very well :(

        – Fifer Sheep
        Apr 3 '15 at 22:06














      2












      2








      2







      You seem to be implicitly asking if there is a place in RAM where the contents of this file are stored. The answer is, "no." The file is simply read and executed during shell startup, then discarded. No Unix shell needs continuous access to its startup script(s).



      Some of the file's contents are still retrievable, per apaul's answer.



      There is a tiny chance that there are fragments of the file itself in freed RAM that hasn't yet been reallocated or returned to the OS, but it's probably not worth your time to try to construct a program to dump the contents of RAM to a disk file and then plow through it to try and find your file contents.



      Take the lessons you've been given and learn from them:




      1. Think twice before pressing Enter on a command involving > instead of >>, just as you have hopefully learned to be careful with rm commands.



      2. Set up Time Machine, soonest.



        Once upon a time, not having a recent backup was a sad but too-common tale. Now it's unforgivable. Apple has gone and made it as easy as you could reasonably ask.








      share|improve this answer















      You seem to be implicitly asking if there is a place in RAM where the contents of this file are stored. The answer is, "no." The file is simply read and executed during shell startup, then discarded. No Unix shell needs continuous access to its startup script(s).



      Some of the file's contents are still retrievable, per apaul's answer.



      There is a tiny chance that there are fragments of the file itself in freed RAM that hasn't yet been reallocated or returned to the OS, but it's probably not worth your time to try to construct a program to dump the contents of RAM to a disk file and then plow through it to try and find your file contents.



      Take the lessons you've been given and learn from them:




      1. Think twice before pressing Enter on a command involving > instead of >>, just as you have hopefully learned to be careful with rm commands.



      2. Set up Time Machine, soonest.



        Once upon a time, not having a recent backup was a sad but too-common tale. Now it's unforgivable. Apple has gone and made it as easy as you could reasonably ask.









      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Apr 13 '17 at 12:36









      Community

      1




      1










      answered Apr 3 '15 at 20:16









      Warren YoungWarren Young

      56.5k11144149




      56.5k11144149













      • Yep, it's exactly what I was asking. I had a feeling that this was the case - and have most certainly learned some valuable lessons! Thank you for confirming, and I will mark this as the answer.

        – Fifer Sheep
        Apr 3 '15 at 21:28











      • I'm somewhat ashamed to admit Richard that I'm studying Software Engineering, and know git very well :(

        – Fifer Sheep
        Apr 3 '15 at 22:06



















      • Yep, it's exactly what I was asking. I had a feeling that this was the case - and have most certainly learned some valuable lessons! Thank you for confirming, and I will mark this as the answer.

        – Fifer Sheep
        Apr 3 '15 at 21:28











      • I'm somewhat ashamed to admit Richard that I'm studying Software Engineering, and know git very well :(

        – Fifer Sheep
        Apr 3 '15 at 22:06

















      Yep, it's exactly what I was asking. I had a feeling that this was the case - and have most certainly learned some valuable lessons! Thank you for confirming, and I will mark this as the answer.

      – Fifer Sheep
      Apr 3 '15 at 21:28





      Yep, it's exactly what I was asking. I had a feeling that this was the case - and have most certainly learned some valuable lessons! Thank you for confirming, and I will mark this as the answer.

      – Fifer Sheep
      Apr 3 '15 at 21:28













      I'm somewhat ashamed to admit Richard that I'm studying Software Engineering, and know git very well :(

      – Fifer Sheep
      Apr 3 '15 at 22:06





      I'm somewhat ashamed to admit Richard that I'm studying Software Engineering, and know git very well :(

      – Fifer Sheep
      Apr 3 '15 at 22:06











      2














      This just happened to me and I recovered as follows...



      Defined vars and functions:



      $ declare > definitions.bash.txt


      Aliases:



      $ alias > aliases.bash.txt





      share|improve this answer




























        2














        This just happened to me and I recovered as follows...



        Defined vars and functions:



        $ declare > definitions.bash.txt


        Aliases:



        $ alias > aliases.bash.txt





        share|improve this answer


























          2












          2








          2







          This just happened to me and I recovered as follows...



          Defined vars and functions:



          $ declare > definitions.bash.txt


          Aliases:



          $ alias > aliases.bash.txt





          share|improve this answer













          This just happened to me and I recovered as follows...



          Defined vars and functions:



          $ declare > definitions.bash.txt


          Aliases:



          $ alias > aliases.bash.txt






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 11 '18 at 12:34









          AnthumChrisAnthumChris

          1213




          1213























              0














              A stupid script did that to my bashrc so I ran the following to retrieve most of my file.



              # Retrieve functions definitions
              $ declare > .bashrc.new
              # Retrieve aliases
              $ alias >> .bashrc.new
              # Retrieve env
              $ echo "export $(env | grep ^PATH=)" >> .bashrc.new


              Here, most of your .bashrc is almost reconstructed. Now you just need to make small adjustements to ensure it matches your best practices. ;)



              A cool command to find the defintion of your custom functions: type my_function >> .bashrc.new.



              Also, make sure to review your env return value to include what you think is important into the newly created file.






              share|improve this answer




























                0














                A stupid script did that to my bashrc so I ran the following to retrieve most of my file.



                # Retrieve functions definitions
                $ declare > .bashrc.new
                # Retrieve aliases
                $ alias >> .bashrc.new
                # Retrieve env
                $ echo "export $(env | grep ^PATH=)" >> .bashrc.new


                Here, most of your .bashrc is almost reconstructed. Now you just need to make small adjustements to ensure it matches your best practices. ;)



                A cool command to find the defintion of your custom functions: type my_function >> .bashrc.new.



                Also, make sure to review your env return value to include what you think is important into the newly created file.






                share|improve this answer


























                  0












                  0








                  0







                  A stupid script did that to my bashrc so I ran the following to retrieve most of my file.



                  # Retrieve functions definitions
                  $ declare > .bashrc.new
                  # Retrieve aliases
                  $ alias >> .bashrc.new
                  # Retrieve env
                  $ echo "export $(env | grep ^PATH=)" >> .bashrc.new


                  Here, most of your .bashrc is almost reconstructed. Now you just need to make small adjustements to ensure it matches your best practices. ;)



                  A cool command to find the defintion of your custom functions: type my_function >> .bashrc.new.



                  Also, make sure to review your env return value to include what you think is important into the newly created file.






                  share|improve this answer













                  A stupid script did that to my bashrc so I ran the following to retrieve most of my file.



                  # Retrieve functions definitions
                  $ declare > .bashrc.new
                  # Retrieve aliases
                  $ alias >> .bashrc.new
                  # Retrieve env
                  $ echo "export $(env | grep ^PATH=)" >> .bashrc.new


                  Here, most of your .bashrc is almost reconstructed. Now you just need to make small adjustements to ensure it matches your best practices. ;)



                  A cool command to find the defintion of your custom functions: type my_function >> .bashrc.new.



                  Also, make sure to review your env return value to include what you think is important into the newly created file.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 19 '18 at 20:47









                  SkyzohKeySkyzohKey

                  1




                  1






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f194278%2fcan-i-recover-my-bash-profile-from-an-open-terminal-tab%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                      Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                      Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...