Making a shorcut ask for what file to open
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
New contributor
add a comment |
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
New contributor
add a comment |
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
New contributor
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
18.04 files gnome-terminal shortcuts
New contributor
New contributor
edited 7 hours ago
Joao Oliveira
New contributor
asked 7 hours ago
Joao OliveiraJoao Oliveira
317
317
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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