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

























  • What about a simple "cd ~/example/path ; gedit"? When gedit lauches, press Ctrl+O and pick your file: de open dialog will by default look into the current directory, which you have set through the cd command. Alternatively, have nautilus open in that folder, and double-click the file you want to open.

    – vanadium
    Feb 15 at 8:10


















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

























  • What about a simple "cd ~/example/path ; gedit"? When gedit lauches, press Ctrl+O and pick your file: de open dialog will by default look into the current directory, which you have set through the cd command. Alternatively, have nautilus open in that folder, and double-click the file you want to open.

    – vanadium
    Feb 15 at 8:10
















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
















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















share|improve this question













share|improve this question




share|improve this question








edited Feb 14 at 21:20







Joao Oliveira

















asked Feb 14 at 21:09









Joao OliveiraJoao Oliveira

339




339













  • What about a simple "cd ~/example/path ; gedit"? When gedit lauches, press Ctrl+O and pick your file: de open dialog will by default look into the current directory, which you have set through the cd command. Alternatively, have nautilus open in that folder, and double-click the file you want to open.

    – vanadium
    Feb 15 at 8:10





















  • What about a simple "cd ~/example/path ; gedit"? When gedit lauches, press Ctrl+O and pick your file: de open dialog will by default look into the current directory, which you have set through the cd command. Alternatively, have nautilus open in that folder, and double-click the file you want to open.

    – vanadium
    Feb 15 at 8:10



















What about a simple "cd ~/example/path ; gedit"? When gedit lauches, press Ctrl+O and pick your file: de open dialog will by default look into the current directory, which you have set through the cd command. Alternatively, have nautilus open in that folder, and double-click the file you want to open.

– vanadium
Feb 15 at 8:10







What about a simple "cd ~/example/path ; gedit"? When gedit lauches, press Ctrl+O and pick your file: de open dialog will by default look into the current directory, which you have set through the cd command. Alternatively, have nautilus open in that folder, and double-click the file you want to open.

– vanadium
Feb 15 at 8:10












1 Answer
1






active

oldest

votes


















2














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
    Feb 14 at 21:41











  • There are plugins for Atom that will allow you to open a terminal at the bottom. Gedit also has plugins for opening a terminal within the app.

    – Kristopher Ives
    Feb 15 at 8:34











  • do you know which and how? the opening the terminal in gedit part i mean

    – Joao Oliveira
    Feb 15 at 15:56











  • See cs50.stackexchange.com/questions/2026/…

    – Kristopher Ives
    Feb 15 at 15:57











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
});


}
});














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









2














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
    Feb 14 at 21:41











  • There are plugins for Atom that will allow you to open a terminal at the bottom. Gedit also has plugins for opening a terminal within the app.

    – Kristopher Ives
    Feb 15 at 8:34











  • do you know which and how? the opening the terminal in gedit part i mean

    – Joao Oliveira
    Feb 15 at 15:56











  • See cs50.stackexchange.com/questions/2026/…

    – Kristopher Ives
    Feb 15 at 15:57
















2














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
    Feb 14 at 21:41











  • There are plugins for Atom that will allow you to open a terminal at the bottom. Gedit also has plugins for opening a terminal within the app.

    – Kristopher Ives
    Feb 15 at 8:34











  • do you know which and how? the opening the terminal in gedit part i mean

    – Joao Oliveira
    Feb 15 at 15:56











  • See cs50.stackexchange.com/questions/2026/…

    – Kristopher Ives
    Feb 15 at 15:57














2












2








2







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 Feb 14 at 21:22









Kristopher IvesKristopher Ives

2,92211525




2,92211525













  • 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
    Feb 14 at 21:41











  • There are plugins for Atom that will allow you to open a terminal at the bottom. Gedit also has plugins for opening a terminal within the app.

    – Kristopher Ives
    Feb 15 at 8:34











  • do you know which and how? the opening the terminal in gedit part i mean

    – Joao Oliveira
    Feb 15 at 15:56











  • See cs50.stackexchange.com/questions/2026/…

    – Kristopher Ives
    Feb 15 at 15:57



















  • 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
    Feb 14 at 21:41











  • There are plugins for Atom that will allow you to open a terminal at the bottom. Gedit also has plugins for opening a terminal within the app.

    – Kristopher Ives
    Feb 15 at 8:34











  • do you know which and how? the opening the terminal in gedit part i mean

    – Joao Oliveira
    Feb 15 at 15:56











  • See cs50.stackexchange.com/questions/2026/…

    – Kristopher Ives
    Feb 15 at 15:57

















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
Feb 14 at 21:41





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
Feb 14 at 21:41













There are plugins for Atom that will allow you to open a terminal at the bottom. Gedit also has plugins for opening a terminal within the app.

– Kristopher Ives
Feb 15 at 8:34





There are plugins for Atom that will allow you to open a terminal at the bottom. Gedit also has plugins for opening a terminal within the app.

– Kristopher Ives
Feb 15 at 8:34













do you know which and how? the opening the terminal in gedit part i mean

– Joao Oliveira
Feb 15 at 15:56





do you know which and how? the opening the terminal in gedit part i mean

– Joao Oliveira
Feb 15 at 15:56













See cs50.stackexchange.com/questions/2026/…

– Kristopher Ives
Feb 15 at 15:57





See cs50.stackexchange.com/questions/2026/…

– Kristopher Ives
Feb 15 at 15:57


















draft saved

draft discarded




















































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

How to make a Squid Proxy server?

第一次世界大戦

Touch on Surface Book