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












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... (n00b!).



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... (n00b!).



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... (n00b!).



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... (n00b!).



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










asked Apr 3 '15 at 19:45









Fifer 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









      apaul

      2,4101712




      2,4101712












      • 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 Young

      54.6k10142146




      54.6k10142146












      • 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









          AnthumChris

          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









                  SkyzohKey

                  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.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • 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

                      Morgemoulin

                      Scott Moir

                      Souastre