How do you “source” a file in fish?












8














I'd like to use keychain with the fish shell, but I'm not sure how to get fish to load the ~/.keychain/hostname-fish file to set the appropriate environment variables.



In bash, there's the "source" command, but it doesn't exist in fish.










share|improve this question





























    8














    I'd like to use keychain with the fish shell, but I'm not sure how to get fish to load the ~/.keychain/hostname-fish file to set the appropriate environment variables.



    In bash, there's the "source" command, but it doesn't exist in fish.










    share|improve this question



























      8












      8








      8


      2





      I'd like to use keychain with the fish shell, but I'm not sure how to get fish to load the ~/.keychain/hostname-fish file to set the appropriate environment variables.



      In bash, there's the "source" command, but it doesn't exist in fish.










      share|improve this question















      I'd like to use keychain with the fish shell, but I'm not sure how to get fish to load the ~/.keychain/hostname-fish file to set the appropriate environment variables.



      In bash, there's the "source" command, but it doesn't exist in fish.







      keychain fish






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 22 '16 at 20:48









      Elijah Lynn

      63831025




      63831025










      asked Dec 17 '09 at 15:33









      Lorin Hochstein

      1,53042224




      1,53042224






















          3 Answers
          3






          active

          oldest

          votes


















          10














          Below is what I have in ~/.config/fish/config.fish for your specific example.



          set -gx HOSTNAME (hostname)
          if status --is-interactive;
          keychain --nogui --clear ~/.ssh/id_rsa
          [ -e $HOME/.keychain/$HOSTNAME-fish ]; and source $HOME/.keychain/$HOSTNAME-fish
          end


          The source command is source, which also works in bash.





          Prior to fish 2.1.0, the source command was called ..






          share|improve this answer























          • @JohnMetta, see the link in the question and funtoo.org/wiki/Keychain. You'll need to install the program.
            – jamessan
            Feb 28 '13 at 2:11










          • Sorry, it was stupid of me to post that. I didn't actually want keychain- I was looking to replace the 'source' command, and didn't actually read. Using . is what I needed.
            – JohnMetta
            Mar 1 '13 at 0:17










          • Thanks for including the [ -e $HOME/.keychain/$HOSTNAME-fish ]; and . $HOME/.keychain/$HOSTNAME-fish line. That got my keychain to work and git to stop asking me for the passphrase every time I wanted to push.
            – cjm
            Aug 26 '16 at 18:34



















          2














          The way recommended on the Keychain documentation page is to put this in config.fish:



          if status --is-interactive
          keychain --eval --quiet --quick path/to/id_rsa
          end


          Then, add this to the top of your script:



          source $HOME/.keychain/(hostname)-fish


          source: http://www.funtoo.org/Keychain






          share|improve this answer































            1














            Use the source command:



            source filename.txt





            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "3"
              };
              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: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              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%2fsuperuser.com%2fquestions%2f84615%2fhow-do-you-source-a-file-in-fish%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              10














              Below is what I have in ~/.config/fish/config.fish for your specific example.



              set -gx HOSTNAME (hostname)
              if status --is-interactive;
              keychain --nogui --clear ~/.ssh/id_rsa
              [ -e $HOME/.keychain/$HOSTNAME-fish ]; and source $HOME/.keychain/$HOSTNAME-fish
              end


              The source command is source, which also works in bash.





              Prior to fish 2.1.0, the source command was called ..






              share|improve this answer























              • @JohnMetta, see the link in the question and funtoo.org/wiki/Keychain. You'll need to install the program.
                – jamessan
                Feb 28 '13 at 2:11










              • Sorry, it was stupid of me to post that. I didn't actually want keychain- I was looking to replace the 'source' command, and didn't actually read. Using . is what I needed.
                – JohnMetta
                Mar 1 '13 at 0:17










              • Thanks for including the [ -e $HOME/.keychain/$HOSTNAME-fish ]; and . $HOME/.keychain/$HOSTNAME-fish line. That got my keychain to work and git to stop asking me for the passphrase every time I wanted to push.
                – cjm
                Aug 26 '16 at 18:34
















              10














              Below is what I have in ~/.config/fish/config.fish for your specific example.



              set -gx HOSTNAME (hostname)
              if status --is-interactive;
              keychain --nogui --clear ~/.ssh/id_rsa
              [ -e $HOME/.keychain/$HOSTNAME-fish ]; and source $HOME/.keychain/$HOSTNAME-fish
              end


              The source command is source, which also works in bash.





              Prior to fish 2.1.0, the source command was called ..






              share|improve this answer























              • @JohnMetta, see the link in the question and funtoo.org/wiki/Keychain. You'll need to install the program.
                – jamessan
                Feb 28 '13 at 2:11










              • Sorry, it was stupid of me to post that. I didn't actually want keychain- I was looking to replace the 'source' command, and didn't actually read. Using . is what I needed.
                – JohnMetta
                Mar 1 '13 at 0:17










              • Thanks for including the [ -e $HOME/.keychain/$HOSTNAME-fish ]; and . $HOME/.keychain/$HOSTNAME-fish line. That got my keychain to work and git to stop asking me for the passphrase every time I wanted to push.
                – cjm
                Aug 26 '16 at 18:34














              10












              10








              10






              Below is what I have in ~/.config/fish/config.fish for your specific example.



              set -gx HOSTNAME (hostname)
              if status --is-interactive;
              keychain --nogui --clear ~/.ssh/id_rsa
              [ -e $HOME/.keychain/$HOSTNAME-fish ]; and source $HOME/.keychain/$HOSTNAME-fish
              end


              The source command is source, which also works in bash.





              Prior to fish 2.1.0, the source command was called ..






              share|improve this answer














              Below is what I have in ~/.config/fish/config.fish for your specific example.



              set -gx HOSTNAME (hostname)
              if status --is-interactive;
              keychain --nogui --clear ~/.ssh/id_rsa
              [ -e $HOME/.keychain/$HOSTNAME-fish ]; and source $HOME/.keychain/$HOSTNAME-fish
              end


              The source command is source, which also works in bash.





              Prior to fish 2.1.0, the source command was called ..







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Dec 6 at 2:09

























              answered Dec 17 '09 at 15:58









              jamessan

              981611




              981611












              • @JohnMetta, see the link in the question and funtoo.org/wiki/Keychain. You'll need to install the program.
                – jamessan
                Feb 28 '13 at 2:11










              • Sorry, it was stupid of me to post that. I didn't actually want keychain- I was looking to replace the 'source' command, and didn't actually read. Using . is what I needed.
                – JohnMetta
                Mar 1 '13 at 0:17










              • Thanks for including the [ -e $HOME/.keychain/$HOSTNAME-fish ]; and . $HOME/.keychain/$HOSTNAME-fish line. That got my keychain to work and git to stop asking me for the passphrase every time I wanted to push.
                – cjm
                Aug 26 '16 at 18:34


















              • @JohnMetta, see the link in the question and funtoo.org/wiki/Keychain. You'll need to install the program.
                – jamessan
                Feb 28 '13 at 2:11










              • Sorry, it was stupid of me to post that. I didn't actually want keychain- I was looking to replace the 'source' command, and didn't actually read. Using . is what I needed.
                – JohnMetta
                Mar 1 '13 at 0:17










              • Thanks for including the [ -e $HOME/.keychain/$HOSTNAME-fish ]; and . $HOME/.keychain/$HOSTNAME-fish line. That got my keychain to work and git to stop asking me for the passphrase every time I wanted to push.
                – cjm
                Aug 26 '16 at 18:34
















              @JohnMetta, see the link in the question and funtoo.org/wiki/Keychain. You'll need to install the program.
              – jamessan
              Feb 28 '13 at 2:11




              @JohnMetta, see the link in the question and funtoo.org/wiki/Keychain. You'll need to install the program.
              – jamessan
              Feb 28 '13 at 2:11












              Sorry, it was stupid of me to post that. I didn't actually want keychain- I was looking to replace the 'source' command, and didn't actually read. Using . is what I needed.
              – JohnMetta
              Mar 1 '13 at 0:17




              Sorry, it was stupid of me to post that. I didn't actually want keychain- I was looking to replace the 'source' command, and didn't actually read. Using . is what I needed.
              – JohnMetta
              Mar 1 '13 at 0:17












              Thanks for including the [ -e $HOME/.keychain/$HOSTNAME-fish ]; and . $HOME/.keychain/$HOSTNAME-fish line. That got my keychain to work and git to stop asking me for the passphrase every time I wanted to push.
              – cjm
              Aug 26 '16 at 18:34




              Thanks for including the [ -e $HOME/.keychain/$HOSTNAME-fish ]; and . $HOME/.keychain/$HOSTNAME-fish line. That got my keychain to work and git to stop asking me for the passphrase every time I wanted to push.
              – cjm
              Aug 26 '16 at 18:34













              2














              The way recommended on the Keychain documentation page is to put this in config.fish:



              if status --is-interactive
              keychain --eval --quiet --quick path/to/id_rsa
              end


              Then, add this to the top of your script:



              source $HOME/.keychain/(hostname)-fish


              source: http://www.funtoo.org/Keychain






              share|improve this answer




























                2














                The way recommended on the Keychain documentation page is to put this in config.fish:



                if status --is-interactive
                keychain --eval --quiet --quick path/to/id_rsa
                end


                Then, add this to the top of your script:



                source $HOME/.keychain/(hostname)-fish


                source: http://www.funtoo.org/Keychain






                share|improve this answer


























                  2












                  2








                  2






                  The way recommended on the Keychain documentation page is to put this in config.fish:



                  if status --is-interactive
                  keychain --eval --quiet --quick path/to/id_rsa
                  end


                  Then, add this to the top of your script:



                  source $HOME/.keychain/(hostname)-fish


                  source: http://www.funtoo.org/Keychain






                  share|improve this answer














                  The way recommended on the Keychain documentation page is to put this in config.fish:



                  if status --is-interactive
                  keychain --eval --quiet --quick path/to/id_rsa
                  end


                  Then, add this to the top of your script:



                  source $HOME/.keychain/(hostname)-fish


                  source: http://www.funtoo.org/Keychain







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 10 '16 at 17:07

























                  answered Jun 28 '15 at 20:41









                  Elijah Lynn

                  63831025




                  63831025























                      1














                      Use the source command:



                      source filename.txt





                      share|improve this answer




























                        1














                        Use the source command:



                        source filename.txt





                        share|improve this answer


























                          1












                          1








                          1






                          Use the source command:



                          source filename.txt





                          share|improve this answer














                          Use the source command:



                          source filename.txt






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Aug 27 '16 at 3:50









                          Heptite

                          14.7k54157




                          14.7k54157










                          answered Aug 26 '16 at 20:16









                          Elijah Lynn

                          63831025




                          63831025






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Super User!


                              • 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%2fsuperuser.com%2fquestions%2f84615%2fhow-do-you-source-a-file-in-fish%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

                              If I really need a card on my start hand, how many mulligans make sense? [duplicate]

                              Alcedinidae

                              Can an atomic nucleus contain both particles and antiparticles? [duplicate]