Making a shorcut ask for what file to open












1















Running Ubuntu 18.04 on a laptop



I want to make a shortcut that when i click it, asks me what file to open(in a certain (pre-established) directory only, not anywhere on the disk) and then opens it for editing using gedit fileName &



Using this command on the terminal works:



sh -c "cd ~/example/path ;gnome-terminal; read fileName; gedit $fileName &"


My reasoning is it travels to the dir im looking for, opens the terminal there, asks for the fileName, then opens with gedit.



On the shortcut the behavior is a bit different. It travels to the right dir, opens the terminal with that path, then opens a new file.(I assume it creates an untitled file because $fileName is nothing i guess)



Is there a way to do this? The simpler the better.
The purpose of this is to open .c files in the directory without having to travel there and save a bit of time, and learn some commands on the way since i'm fairly new.










share|improve this question









New contributor




Joao Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1















    Running Ubuntu 18.04 on a laptop



    I want to make a shortcut that when i click it, asks me what file to open(in a certain (pre-established) directory only, not anywhere on the disk) and then opens it for editing using gedit fileName &



    Using this command on the terminal works:



    sh -c "cd ~/example/path ;gnome-terminal; read fileName; gedit $fileName &"


    My reasoning is it travels to the dir im looking for, opens the terminal there, asks for the fileName, then opens with gedit.



    On the shortcut the behavior is a bit different. It travels to the right dir, opens the terminal with that path, then opens a new file.(I assume it creates an untitled file because $fileName is nothing i guess)



    Is there a way to do this? The simpler the better.
    The purpose of this is to open .c files in the directory without having to travel there and save a bit of time, and learn some commands on the way since i'm fairly new.










    share|improve this question









    New contributor




    Joao Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1








      Running Ubuntu 18.04 on a laptop



      I want to make a shortcut that when i click it, asks me what file to open(in a certain (pre-established) directory only, not anywhere on the disk) and then opens it for editing using gedit fileName &



      Using this command on the terminal works:



      sh -c "cd ~/example/path ;gnome-terminal; read fileName; gedit $fileName &"


      My reasoning is it travels to the dir im looking for, opens the terminal there, asks for the fileName, then opens with gedit.



      On the shortcut the behavior is a bit different. It travels to the right dir, opens the terminal with that path, then opens a new file.(I assume it creates an untitled file because $fileName is nothing i guess)



      Is there a way to do this? The simpler the better.
      The purpose of this is to open .c files in the directory without having to travel there and save a bit of time, and learn some commands on the way since i'm fairly new.










      share|improve this question









      New contributor




      Joao Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      Running Ubuntu 18.04 on a laptop



      I want to make a shortcut that when i click it, asks me what file to open(in a certain (pre-established) directory only, not anywhere on the disk) and then opens it for editing using gedit fileName &



      Using this command on the terminal works:



      sh -c "cd ~/example/path ;gnome-terminal; read fileName; gedit $fileName &"


      My reasoning is it travels to the dir im looking for, opens the terminal there, asks for the fileName, then opens with gedit.



      On the shortcut the behavior is a bit different. It travels to the right dir, opens the terminal with that path, then opens a new file.(I assume it creates an untitled file because $fileName is nothing i guess)



      Is there a way to do this? The simpler the better.
      The purpose of this is to open .c files in the directory without having to travel there and save a bit of time, and learn some commands on the way since i'm fairly new.







      18.04 files gnome-terminal shortcuts






      share|improve this question









      New contributor




      Joao Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Joao Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 7 hours ago







      Joao Oliveira













      New contributor




      Joao Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 7 hours ago









      Joao OliveiraJoao Oliveira

      317




      317




      New contributor




      Joao Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Joao Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Joao Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Atom has support for this by pressing Ctrl+P which lets you start typing a filename and it will show the closest matches.



          Also be aware that & only sends a process into the background, when you close the parent process (like your terminal) it will kill all the spawned gedit processes. You may want to use nohup or setsid to avoid that.






          share|improve this answer
























          • Well, I want to keep the terminal open, since its a .c file, I want to compile it and run it from there without having to close the file every time, so the &

            – Joao Oliveira
            6 hours ago











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          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
          });


          }
          });






          Joao Oliveira is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1118339%2fmaking-a-shorcut-ask-for-what-file-to-open%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Atom has support for this by pressing Ctrl+P which lets you start typing a filename and it will show the closest matches.



          Also be aware that & only sends a process into the background, when you close the parent process (like your terminal) it will kill all the spawned gedit processes. You may want to use nohup or setsid to avoid that.






          share|improve this answer
























          • Well, I want to keep the terminal open, since its a .c file, I want to compile it and run it from there without having to close the file every time, so the &

            – Joao Oliveira
            6 hours ago
















          1














          Atom has support for this by pressing Ctrl+P which lets you start typing a filename and it will show the closest matches.



          Also be aware that & only sends a process into the background, when you close the parent process (like your terminal) it will kill all the spawned gedit processes. You may want to use nohup or setsid to avoid that.






          share|improve this answer
























          • Well, I want to keep the terminal open, since its a .c file, I want to compile it and run it from there without having to close the file every time, so the &

            – Joao Oliveira
            6 hours ago














          1












          1








          1







          Atom has support for this by pressing Ctrl+P which lets you start typing a filename and it will show the closest matches.



          Also be aware that & only sends a process into the background, when you close the parent process (like your terminal) it will kill all the spawned gedit processes. You may want to use nohup or setsid to avoid that.






          share|improve this answer













          Atom has support for this by pressing Ctrl+P which lets you start typing a filename and it will show the closest matches.



          Also be aware that & only sends a process into the background, when you close the parent process (like your terminal) it will kill all the spawned gedit processes. You may want to use nohup or setsid to avoid that.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 7 hours ago









          Kristopher IvesKristopher Ives

          2,76811323




          2,76811323













          • Well, I want to keep the terminal open, since its a .c file, I want to compile it and run it from there without having to close the file every time, so the &

            – Joao Oliveira
            6 hours ago



















          • Well, I want to keep the terminal open, since its a .c file, I want to compile it and run it from there without having to close the file every time, so the &

            – Joao Oliveira
            6 hours ago

















          Well, I want to keep the terminal open, since its a .c file, I want to compile it and run it from there without having to close the file every time, so the &

          – Joao Oliveira
          6 hours ago





          Well, I want to keep the terminal open, since its a .c file, I want to compile it and run it from there without having to close the file every time, so the &

          – Joao Oliveira
          6 hours ago










          Joao Oliveira is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Joao Oliveira is a new contributor. Be nice, and check out our Code of Conduct.













          Joao Oliveira is a new contributor. Be nice, and check out our Code of Conduct.












          Joao Oliveira is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Ask Ubuntu!


          • 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%2faskubuntu.com%2fquestions%2f1118339%2fmaking-a-shorcut-ask-for-what-file-to-open%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

          數位音樂下載

          When can things happen in Etherscan, such as the picture below?

          格利澤436b