How can I start my application in a more convenient way? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How do I run executable scripts in Nautilus?How to make a file (e.g. a .sh script) executable, so it can be run from terminalHow do I create a script file for terminal commands?Open Any file with specific Program?How to associate all file types within Wine with its corresponding native application?Help or advice for my scriptScript to quit and restart nautilus doesn't workThere was an error creating the child process for this terminalHow to run perl script in backgroundHow to start GUI application with upstart?making a bash script executable programaticallyHow can I run a script when the power supply is plugged-in or -out?Find and Rename recursively in folders, subfolders and multiple filesHow do I check if I can safely install something with apt during a bash script?

Tips to organize LaTeX presentations for a semester

Where is the Next Backup Size entry on iOS 12?

Most effective melee weapons for arboreal combat? (pre-gunpowder technology)

How can a team of shapeshifters communicate?

Does the Black Tentacles spell do damage twice at the start of turn to an already restrained creature?

Is multiple magic items in one inherently imbalanced?

Why is it faster to reheat something than it is to cook it?

Putting class ranking in CV, but against dept guidelines

What is the origin of 落第?

Can two people see the same photon?

What does it mean that physics no longer uses mechanical models to describe phenomena?

Caught masturbating at work

Why weren't discrete x86 CPUs ever used in game hardware?

Why are vacuum tubes still used in amateur radios?

Is openssl rand command cryptographically secure?

Flight departed from the gate 5 min before scheduled departure time. Refund options

Did pre-Columbian Americans know the spherical shape of the Earth?

Relating to the President and obstruction, were Mueller's conclusions preordained?

Printing attributes of selection in ArcPy?

Special flights

How many time has Arya actually used Needle?

A term for a woman complaining about things/begging in a cute/childish way

what is the log of the PDF for a Normal Distribution?

Why datecode is SO IMPORTANT to chip manufacturers?



How can I start my application in a more convenient way?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)How do I run executable scripts in Nautilus?How to make a file (e.g. a .sh script) executable, so it can be run from terminalHow do I create a script file for terminal commands?Open Any file with specific Program?How to associate all file types within Wine with its corresponding native application?Help or advice for my scriptScript to quit and restart nautilus doesn't workThere was an error creating the child process for this terminalHow to run perl script in backgroundHow to start GUI application with upstart?making a bash script executable programaticallyHow can I run a script when the power supply is plugged-in or -out?Find and Rename recursively in folders, subfolders and multiple filesHow do I check if I can safely install something with apt during a bash script?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








9















I am new in Ubuntu. I have an application which I open in the following way. I type in the console:



cd ~/MyDirectory
./myapp +some arguments


How can I find a solution, so I could launch my application without typing these commands in the console every time? I am thinking of a script, like a bat-script or .lnk in windows.



In other similar questions I didn't find a solution because there was only some mention and discussion of scripting. I didn't find how I can use "cd" command in other questions, and this question is not duplicate of others I suggest.










share|improve this question
























  • @steeldriver, no, i didn't found solution at this question. there are no anything about cd command and running app via script.

    – nick
    Apr 1 at 13:35












  • #1 Do you want the solution to be an icon you can click on your desktop, or will this be something which you need/want to run from the command prompt? #2 How often will the argument change?

    – RonJohn
    Apr 1 at 22:23











  • The conversation (safely in this case) assumes there is a desktop. Quite often in the scripting world there will not be.

    – mckenzm
    Apr 2 at 0:22

















9















I am new in Ubuntu. I have an application which I open in the following way. I type in the console:



cd ~/MyDirectory
./myapp +some arguments


How can I find a solution, so I could launch my application without typing these commands in the console every time? I am thinking of a script, like a bat-script or .lnk in windows.



In other similar questions I didn't find a solution because there was only some mention and discussion of scripting. I didn't find how I can use "cd" command in other questions, and this question is not duplicate of others I suggest.










share|improve this question
























  • @steeldriver, no, i didn't found solution at this question. there are no anything about cd command and running app via script.

    – nick
    Apr 1 at 13:35












  • #1 Do you want the solution to be an icon you can click on your desktop, or will this be something which you need/want to run from the command prompt? #2 How often will the argument change?

    – RonJohn
    Apr 1 at 22:23











  • The conversation (safely in this case) assumes there is a desktop. Quite often in the scripting world there will not be.

    – mckenzm
    Apr 2 at 0:22













9












9








9


1






I am new in Ubuntu. I have an application which I open in the following way. I type in the console:



cd ~/MyDirectory
./myapp +some arguments


How can I find a solution, so I could launch my application without typing these commands in the console every time? I am thinking of a script, like a bat-script or .lnk in windows.



In other similar questions I didn't find a solution because there was only some mention and discussion of scripting. I didn't find how I can use "cd" command in other questions, and this question is not duplicate of others I suggest.










share|improve this question
















I am new in Ubuntu. I have an application which I open in the following way. I type in the console:



cd ~/MyDirectory
./myapp +some arguments


How can I find a solution, so I could launch my application without typing these commands in the console every time? I am thinking of a script, like a bat-script or .lnk in windows.



In other similar questions I didn't find a solution because there was only some mention and discussion of scripting. I didn't find how I can use "cd" command in other questions, and this question is not duplicate of others I suggest.







scripts






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 2 at 14:13









rabipelais

11314




11314










asked Apr 1 at 13:28









nicknick

1506




1506












  • @steeldriver, no, i didn't found solution at this question. there are no anything about cd command and running app via script.

    – nick
    Apr 1 at 13:35












  • #1 Do you want the solution to be an icon you can click on your desktop, or will this be something which you need/want to run from the command prompt? #2 How often will the argument change?

    – RonJohn
    Apr 1 at 22:23











  • The conversation (safely in this case) assumes there is a desktop. Quite often in the scripting world there will not be.

    – mckenzm
    Apr 2 at 0:22

















  • @steeldriver, no, i didn't found solution at this question. there are no anything about cd command and running app via script.

    – nick
    Apr 1 at 13:35












  • #1 Do you want the solution to be an icon you can click on your desktop, or will this be something which you need/want to run from the command prompt? #2 How often will the argument change?

    – RonJohn
    Apr 1 at 22:23











  • The conversation (safely in this case) assumes there is a desktop. Quite often in the scripting world there will not be.

    – mckenzm
    Apr 2 at 0:22
















@steeldriver, no, i didn't found solution at this question. there are no anything about cd command and running app via script.

– nick
Apr 1 at 13:35






@steeldriver, no, i didn't found solution at this question. there are no anything about cd command and running app via script.

– nick
Apr 1 at 13:35














#1 Do you want the solution to be an icon you can click on your desktop, or will this be something which you need/want to run from the command prompt? #2 How often will the argument change?

– RonJohn
Apr 1 at 22:23





#1 Do you want the solution to be an icon you can click on your desktop, or will this be something which you need/want to run from the command prompt? #2 How often will the argument change?

– RonJohn
Apr 1 at 22:23













The conversation (safely in this case) assumes there is a desktop. Quite often in the scripting world there will not be.

– mckenzm
Apr 2 at 0:22





The conversation (safely in this case) assumes there is a desktop. Quite often in the scripting world there will not be.

– mckenzm
Apr 2 at 0:22










3 Answers
3






active

oldest

votes


















21














A script is quite overkill.



Use a .desktop file like:



[Desktop Entry]
Exec=/bin/bash -c "cd ~/MyDirectory && myapp some_arguments"
Name=Some App
Type=Application


  • Save it as some_app.desktop

  • Make it executable and double click

N.B.



The question is if it needs to be run from its own directory or not. If not, the command could even be simpler:



Exec='/home/MyUserName/MyDirectory/myapp' some_arguments





share|improve this answer




















  • 2





    Really thank you. .desktop file is enough for this task.

    – nick
    Apr 1 at 13:52






  • 2





    @allo If OP asks for a solution, which isn't the optimal one for his problem, but he isn't aware a better one exists, you should give him the better solution for his problem if you know one. If you don't see that you are quite missing the point on what an answer should be here.

    – Jacob Vlijm
    Apr 1 at 15:34







  • 1





    @dessert Thanks for the edit. We might have to deal with paths with spaces :)

    – Jacob Vlijm
    Apr 1 at 16:27






  • 1





    You might want to write ./myapp … instead of just myapp … because the current directory, ., by default is not part of the PATH variable.

    – PerlDuck
    Apr 2 at 9:42






  • 1





    @allo Please feel free to add your own answer if you think the existing ones are not sufficient.

    – Fabby
    Apr 2 at 18:01


















12














Create a file with following content:



#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments


Then make it executable:



chmod u+x scriptname


Now you can call script like: /pathtoscript/scriptname



You can combine this with answer by v010dya, and put script in bin what is in the $PATH, so both calling methods are possible: in shell in any directory type scriptname or use desktop shortcut explained below. Just change /pathtoscript to actual placement of script.



Make a shortcut to script, place in in ~/.local/share/applications/ and name like somename.desktop with the following content:



[Desktop Entry]
Version=1.0
Name=Script
Comment=
Keywords=Script
Exec=/pathtoscript/scriptname
Terminal=false
X-MultipleArgs=true
Type=Application
Icon=preferences-system
Categories=GTK;Development;
StartupNotify=false


Then it will appear in applications list






share|improve this answer




















  • 1





    Your answer is working, thank you. But really sorry, script is too hard, I didn't knew about it. And my answer was concretically in script but not in just finding any way of solution. I will +1 to you.

    – nick
    Apr 1 at 13:54


















1














Although you have already found a solution that you can double click on, there's a solution that makes it more trivial to run from command line:



Step 1 - Write a script



This is already covered by an answer of LeonidMew, i will copy it here:



#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments


and then



chmod u+x scriptname


Step 2 - Make it easy to execute



You need to create a directory ~/bin and make bash search it for commands. So in terminal we write:



mkdir ~/bin
mv scriptname ~/bin
vim ~/.profile


Here i am doing everything in terminal, you can of course create a directory dir in your home directory and also move your script there via graphical tools that you are comfortable with. Also i am using vim as an editor, but it is a little difficult for beginners to use, i would advise you to learn, but you can just use a different editor (even graphical) to edit .profile inside your home directory, note that this file is hidden by default.



You need to add the following to an end of that file



# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi


If you are using vim you press i to start adding text, and then Esc to end adding. After that you input :wq to write file and exit. Or, as i have already said, use a more simple editor.



Step 3 - Enjoy



Now, it will not matter what directory you are in, you can always just type scriptname and press Enter. You can also place other scripts and applications that you want to be executable in ~/bin.






share|improve this answer


















  • 1





    You wrote how to exit of vim, +1 Just kidding, nice answer. Your solution is useful. It still possible to create .desktop file, to run script from apps list or menu(depending on DE). After patching .profile logout/login is needed. Also home can be mounted with noexec option, in this case its needed to put script in /usr/local/bin/ (using sudo).

    – LeonidMew
    Apr 7 at 9:14











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%2f1130354%2fhow-can-i-start-my-application-in-a-more-convenient-way%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









21














A script is quite overkill.



Use a .desktop file like:



[Desktop Entry]
Exec=/bin/bash -c "cd ~/MyDirectory && myapp some_arguments"
Name=Some App
Type=Application


  • Save it as some_app.desktop

  • Make it executable and double click

N.B.



The question is if it needs to be run from its own directory or not. If not, the command could even be simpler:



Exec='/home/MyUserName/MyDirectory/myapp' some_arguments





share|improve this answer




















  • 2





    Really thank you. .desktop file is enough for this task.

    – nick
    Apr 1 at 13:52






  • 2





    @allo If OP asks for a solution, which isn't the optimal one for his problem, but he isn't aware a better one exists, you should give him the better solution for his problem if you know one. If you don't see that you are quite missing the point on what an answer should be here.

    – Jacob Vlijm
    Apr 1 at 15:34







  • 1





    @dessert Thanks for the edit. We might have to deal with paths with spaces :)

    – Jacob Vlijm
    Apr 1 at 16:27






  • 1





    You might want to write ./myapp … instead of just myapp … because the current directory, ., by default is not part of the PATH variable.

    – PerlDuck
    Apr 2 at 9:42






  • 1





    @allo Please feel free to add your own answer if you think the existing ones are not sufficient.

    – Fabby
    Apr 2 at 18:01















21














A script is quite overkill.



Use a .desktop file like:



[Desktop Entry]
Exec=/bin/bash -c "cd ~/MyDirectory && myapp some_arguments"
Name=Some App
Type=Application


  • Save it as some_app.desktop

  • Make it executable and double click

N.B.



The question is if it needs to be run from its own directory or not. If not, the command could even be simpler:



Exec='/home/MyUserName/MyDirectory/myapp' some_arguments





share|improve this answer




















  • 2





    Really thank you. .desktop file is enough for this task.

    – nick
    Apr 1 at 13:52






  • 2





    @allo If OP asks for a solution, which isn't the optimal one for his problem, but he isn't aware a better one exists, you should give him the better solution for his problem if you know one. If you don't see that you are quite missing the point on what an answer should be here.

    – Jacob Vlijm
    Apr 1 at 15:34







  • 1





    @dessert Thanks for the edit. We might have to deal with paths with spaces :)

    – Jacob Vlijm
    Apr 1 at 16:27






  • 1





    You might want to write ./myapp … instead of just myapp … because the current directory, ., by default is not part of the PATH variable.

    – PerlDuck
    Apr 2 at 9:42






  • 1





    @allo Please feel free to add your own answer if you think the existing ones are not sufficient.

    – Fabby
    Apr 2 at 18:01













21












21








21







A script is quite overkill.



Use a .desktop file like:



[Desktop Entry]
Exec=/bin/bash -c "cd ~/MyDirectory && myapp some_arguments"
Name=Some App
Type=Application


  • Save it as some_app.desktop

  • Make it executable and double click

N.B.



The question is if it needs to be run from its own directory or not. If not, the command could even be simpler:



Exec='/home/MyUserName/MyDirectory/myapp' some_arguments





share|improve this answer















A script is quite overkill.



Use a .desktop file like:



[Desktop Entry]
Exec=/bin/bash -c "cd ~/MyDirectory && myapp some_arguments"
Name=Some App
Type=Application


  • Save it as some_app.desktop

  • Make it executable and double click

N.B.



The question is if it needs to be run from its own directory or not. If not, the command could even be simpler:



Exec='/home/MyUserName/MyDirectory/myapp' some_arguments






share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 1 at 16:25

























answered Apr 1 at 13:48









Jacob VlijmJacob Vlijm

66.7k9137234




66.7k9137234







  • 2





    Really thank you. .desktop file is enough for this task.

    – nick
    Apr 1 at 13:52






  • 2





    @allo If OP asks for a solution, which isn't the optimal one for his problem, but he isn't aware a better one exists, you should give him the better solution for his problem if you know one. If you don't see that you are quite missing the point on what an answer should be here.

    – Jacob Vlijm
    Apr 1 at 15:34







  • 1





    @dessert Thanks for the edit. We might have to deal with paths with spaces :)

    – Jacob Vlijm
    Apr 1 at 16:27






  • 1





    You might want to write ./myapp … instead of just myapp … because the current directory, ., by default is not part of the PATH variable.

    – PerlDuck
    Apr 2 at 9:42






  • 1





    @allo Please feel free to add your own answer if you think the existing ones are not sufficient.

    – Fabby
    Apr 2 at 18:01












  • 2





    Really thank you. .desktop file is enough for this task.

    – nick
    Apr 1 at 13:52






  • 2





    @allo If OP asks for a solution, which isn't the optimal one for his problem, but he isn't aware a better one exists, you should give him the better solution for his problem if you know one. If you don't see that you are quite missing the point on what an answer should be here.

    – Jacob Vlijm
    Apr 1 at 15:34







  • 1





    @dessert Thanks for the edit. We might have to deal with paths with spaces :)

    – Jacob Vlijm
    Apr 1 at 16:27






  • 1





    You might want to write ./myapp … instead of just myapp … because the current directory, ., by default is not part of the PATH variable.

    – PerlDuck
    Apr 2 at 9:42






  • 1





    @allo Please feel free to add your own answer if you think the existing ones are not sufficient.

    – Fabby
    Apr 2 at 18:01







2




2





Really thank you. .desktop file is enough for this task.

– nick
Apr 1 at 13:52





Really thank you. .desktop file is enough for this task.

– nick
Apr 1 at 13:52




2




2





@allo If OP asks for a solution, which isn't the optimal one for his problem, but he isn't aware a better one exists, you should give him the better solution for his problem if you know one. If you don't see that you are quite missing the point on what an answer should be here.

– Jacob Vlijm
Apr 1 at 15:34






@allo If OP asks for a solution, which isn't the optimal one for his problem, but he isn't aware a better one exists, you should give him the better solution for his problem if you know one. If you don't see that you are quite missing the point on what an answer should be here.

– Jacob Vlijm
Apr 1 at 15:34





1




1





@dessert Thanks for the edit. We might have to deal with paths with spaces :)

– Jacob Vlijm
Apr 1 at 16:27





@dessert Thanks for the edit. We might have to deal with paths with spaces :)

– Jacob Vlijm
Apr 1 at 16:27




1




1





You might want to write ./myapp … instead of just myapp … because the current directory, ., by default is not part of the PATH variable.

– PerlDuck
Apr 2 at 9:42





You might want to write ./myapp … instead of just myapp … because the current directory, ., by default is not part of the PATH variable.

– PerlDuck
Apr 2 at 9:42




1




1





@allo Please feel free to add your own answer if you think the existing ones are not sufficient.

– Fabby
Apr 2 at 18:01





@allo Please feel free to add your own answer if you think the existing ones are not sufficient.

– Fabby
Apr 2 at 18:01













12














Create a file with following content:



#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments


Then make it executable:



chmod u+x scriptname


Now you can call script like: /pathtoscript/scriptname



You can combine this with answer by v010dya, and put script in bin what is in the $PATH, so both calling methods are possible: in shell in any directory type scriptname or use desktop shortcut explained below. Just change /pathtoscript to actual placement of script.



Make a shortcut to script, place in in ~/.local/share/applications/ and name like somename.desktop with the following content:



[Desktop Entry]
Version=1.0
Name=Script
Comment=
Keywords=Script
Exec=/pathtoscript/scriptname
Terminal=false
X-MultipleArgs=true
Type=Application
Icon=preferences-system
Categories=GTK;Development;
StartupNotify=false


Then it will appear in applications list






share|improve this answer




















  • 1





    Your answer is working, thank you. But really sorry, script is too hard, I didn't knew about it. And my answer was concretically in script but not in just finding any way of solution. I will +1 to you.

    – nick
    Apr 1 at 13:54















12














Create a file with following content:



#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments


Then make it executable:



chmod u+x scriptname


Now you can call script like: /pathtoscript/scriptname



You can combine this with answer by v010dya, and put script in bin what is in the $PATH, so both calling methods are possible: in shell in any directory type scriptname or use desktop shortcut explained below. Just change /pathtoscript to actual placement of script.



Make a shortcut to script, place in in ~/.local/share/applications/ and name like somename.desktop with the following content:



[Desktop Entry]
Version=1.0
Name=Script
Comment=
Keywords=Script
Exec=/pathtoscript/scriptname
Terminal=false
X-MultipleArgs=true
Type=Application
Icon=preferences-system
Categories=GTK;Development;
StartupNotify=false


Then it will appear in applications list






share|improve this answer




















  • 1





    Your answer is working, thank you. But really sorry, script is too hard, I didn't knew about it. And my answer was concretically in script but not in just finding any way of solution. I will +1 to you.

    – nick
    Apr 1 at 13:54













12












12








12







Create a file with following content:



#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments


Then make it executable:



chmod u+x scriptname


Now you can call script like: /pathtoscript/scriptname



You can combine this with answer by v010dya, and put script in bin what is in the $PATH, so both calling methods are possible: in shell in any directory type scriptname or use desktop shortcut explained below. Just change /pathtoscript to actual placement of script.



Make a shortcut to script, place in in ~/.local/share/applications/ and name like somename.desktop with the following content:



[Desktop Entry]
Version=1.0
Name=Script
Comment=
Keywords=Script
Exec=/pathtoscript/scriptname
Terminal=false
X-MultipleArgs=true
Type=Application
Icon=preferences-system
Categories=GTK;Development;
StartupNotify=false


Then it will appear in applications list






share|improve this answer















Create a file with following content:



#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments


Then make it executable:



chmod u+x scriptname


Now you can call script like: /pathtoscript/scriptname



You can combine this with answer by v010dya, and put script in bin what is in the $PATH, so both calling methods are possible: in shell in any directory type scriptname or use desktop shortcut explained below. Just change /pathtoscript to actual placement of script.



Make a shortcut to script, place in in ~/.local/share/applications/ and name like somename.desktop with the following content:



[Desktop Entry]
Version=1.0
Name=Script
Comment=
Keywords=Script
Exec=/pathtoscript/scriptname
Terminal=false
X-MultipleArgs=true
Type=Application
Icon=preferences-system
Categories=GTK;Development;
StartupNotify=false


Then it will appear in applications list







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 7 at 10:04

























answered Apr 1 at 13:36









LeonidMewLeonidMew

971623




971623







  • 1





    Your answer is working, thank you. But really sorry, script is too hard, I didn't knew about it. And my answer was concretically in script but not in just finding any way of solution. I will +1 to you.

    – nick
    Apr 1 at 13:54












  • 1





    Your answer is working, thank you. But really sorry, script is too hard, I didn't knew about it. And my answer was concretically in script but not in just finding any way of solution. I will +1 to you.

    – nick
    Apr 1 at 13:54







1




1





Your answer is working, thank you. But really sorry, script is too hard, I didn't knew about it. And my answer was concretically in script but not in just finding any way of solution. I will +1 to you.

– nick
Apr 1 at 13:54





Your answer is working, thank you. But really sorry, script is too hard, I didn't knew about it. And my answer was concretically in script but not in just finding any way of solution. I will +1 to you.

– nick
Apr 1 at 13:54











1














Although you have already found a solution that you can double click on, there's a solution that makes it more trivial to run from command line:



Step 1 - Write a script



This is already covered by an answer of LeonidMew, i will copy it here:



#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments


and then



chmod u+x scriptname


Step 2 - Make it easy to execute



You need to create a directory ~/bin and make bash search it for commands. So in terminal we write:



mkdir ~/bin
mv scriptname ~/bin
vim ~/.profile


Here i am doing everything in terminal, you can of course create a directory dir in your home directory and also move your script there via graphical tools that you are comfortable with. Also i am using vim as an editor, but it is a little difficult for beginners to use, i would advise you to learn, but you can just use a different editor (even graphical) to edit .profile inside your home directory, note that this file is hidden by default.



You need to add the following to an end of that file



# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi


If you are using vim you press i to start adding text, and then Esc to end adding. After that you input :wq to write file and exit. Or, as i have already said, use a more simple editor.



Step 3 - Enjoy



Now, it will not matter what directory you are in, you can always just type scriptname and press Enter. You can also place other scripts and applications that you want to be executable in ~/bin.






share|improve this answer


















  • 1





    You wrote how to exit of vim, +1 Just kidding, nice answer. Your solution is useful. It still possible to create .desktop file, to run script from apps list or menu(depending on DE). After patching .profile logout/login is needed. Also home can be mounted with noexec option, in this case its needed to put script in /usr/local/bin/ (using sudo).

    – LeonidMew
    Apr 7 at 9:14















1














Although you have already found a solution that you can double click on, there's a solution that makes it more trivial to run from command line:



Step 1 - Write a script



This is already covered by an answer of LeonidMew, i will copy it here:



#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments


and then



chmod u+x scriptname


Step 2 - Make it easy to execute



You need to create a directory ~/bin and make bash search it for commands. So in terminal we write:



mkdir ~/bin
mv scriptname ~/bin
vim ~/.profile


Here i am doing everything in terminal, you can of course create a directory dir in your home directory and also move your script there via graphical tools that you are comfortable with. Also i am using vim as an editor, but it is a little difficult for beginners to use, i would advise you to learn, but you can just use a different editor (even graphical) to edit .profile inside your home directory, note that this file is hidden by default.



You need to add the following to an end of that file



# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi


If you are using vim you press i to start adding text, and then Esc to end adding. After that you input :wq to write file and exit. Or, as i have already said, use a more simple editor.



Step 3 - Enjoy



Now, it will not matter what directory you are in, you can always just type scriptname and press Enter. You can also place other scripts and applications that you want to be executable in ~/bin.






share|improve this answer


















  • 1





    You wrote how to exit of vim, +1 Just kidding, nice answer. Your solution is useful. It still possible to create .desktop file, to run script from apps list or menu(depending on DE). After patching .profile logout/login is needed. Also home can be mounted with noexec option, in this case its needed to put script in /usr/local/bin/ (using sudo).

    – LeonidMew
    Apr 7 at 9:14













1












1








1







Although you have already found a solution that you can double click on, there's a solution that makes it more trivial to run from command line:



Step 1 - Write a script



This is already covered by an answer of LeonidMew, i will copy it here:



#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments


and then



chmod u+x scriptname


Step 2 - Make it easy to execute



You need to create a directory ~/bin and make bash search it for commands. So in terminal we write:



mkdir ~/bin
mv scriptname ~/bin
vim ~/.profile


Here i am doing everything in terminal, you can of course create a directory dir in your home directory and also move your script there via graphical tools that you are comfortable with. Also i am using vim as an editor, but it is a little difficult for beginners to use, i would advise you to learn, but you can just use a different editor (even graphical) to edit .profile inside your home directory, note that this file is hidden by default.



You need to add the following to an end of that file



# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi


If you are using vim you press i to start adding text, and then Esc to end adding. After that you input :wq to write file and exit. Or, as i have already said, use a more simple editor.



Step 3 - Enjoy



Now, it will not matter what directory you are in, you can always just type scriptname and press Enter. You can also place other scripts and applications that you want to be executable in ~/bin.






share|improve this answer













Although you have already found a solution that you can double click on, there's a solution that makes it more trivial to run from command line:



Step 1 - Write a script



This is already covered by an answer of LeonidMew, i will copy it here:



#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments


and then



chmod u+x scriptname


Step 2 - Make it easy to execute



You need to create a directory ~/bin and make bash search it for commands. So in terminal we write:



mkdir ~/bin
mv scriptname ~/bin
vim ~/.profile


Here i am doing everything in terminal, you can of course create a directory dir in your home directory and also move your script there via graphical tools that you are comfortable with. Also i am using vim as an editor, but it is a little difficult for beginners to use, i would advise you to learn, but you can just use a different editor (even graphical) to edit .profile inside your home directory, note that this file is hidden by default.



You need to add the following to an end of that file



# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi


If you are using vim you press i to start adding text, and then Esc to end adding. After that you input :wq to write file and exit. Or, as i have already said, use a more simple editor.



Step 3 - Enjoy



Now, it will not matter what directory you are in, you can always just type scriptname and press Enter. You can also place other scripts and applications that you want to be executable in ~/bin.







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 7 at 5:14









v010dyav010dya

7022929




7022929







  • 1





    You wrote how to exit of vim, +1 Just kidding, nice answer. Your solution is useful. It still possible to create .desktop file, to run script from apps list or menu(depending on DE). After patching .profile logout/login is needed. Also home can be mounted with noexec option, in this case its needed to put script in /usr/local/bin/ (using sudo).

    – LeonidMew
    Apr 7 at 9:14












  • 1





    You wrote how to exit of vim, +1 Just kidding, nice answer. Your solution is useful. It still possible to create .desktop file, to run script from apps list or menu(depending on DE). After patching .profile logout/login is needed. Also home can be mounted with noexec option, in this case its needed to put script in /usr/local/bin/ (using sudo).

    – LeonidMew
    Apr 7 at 9:14







1




1





You wrote how to exit of vim, +1 Just kidding, nice answer. Your solution is useful. It still possible to create .desktop file, to run script from apps list or menu(depending on DE). After patching .profile logout/login is needed. Also home can be mounted with noexec option, in this case its needed to put script in /usr/local/bin/ (using sudo).

– LeonidMew
Apr 7 at 9:14





You wrote how to exit of vim, +1 Just kidding, nice answer. Your solution is useful. It still possible to create .desktop file, to run script from apps list or menu(depending on DE). After patching .profile logout/login is needed. Also home can be mounted with noexec option, in this case its needed to put script in /usr/local/bin/ (using sudo).

– LeonidMew
Apr 7 at 9:14

















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%2f1130354%2fhow-can-i-start-my-application-in-a-more-convenient-way%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

Triangular numbers and gcdProving sum of a set is $0 pmod n$ if $n$ is odd, or $fracn2 pmod n$ if $n$ is even?Is greatest common divisor of two numbers really their smallest linear combination?GCD, LCM RelationshipProve a set of nonnegative integers with greatest common divisor 1 and closed under addition has all but finite many nonnegative integers.all pairs of a and b in an equation containing gcdTriangular Numbers Modulo $k$ - Hit All Values?Understanding the Existence and Uniqueness of the GCDGCD and LCM with logical symbolsThe greatest common divisor of two positive integers less than 100 is equal to 3. Their least common multiple is twelve times one of the integers.Suppose that for all integers $x$, $x|a$ and $x|b$ if and only if $x|c$. Then $c = gcd(a,b)$Which is the gcd of 2 numbers which are multiplied and the result is 600000?

Ingelân Ynhâld Etymology | Geografy | Skiednis | Polityk en bestjoer | Ekonomy | Demografy | Kultuer | Klimaat | Sjoch ek | Keppelings om utens | Boarnen, noaten en referinsjes Navigaasjemenuwww.gov.ukOffisjele webside fan it regear fan it Feriene KeninkrykOffisjele webside fan it Britske FerkearsburoNederlânsktalige ynformaasje fan it Britske FerkearsburoOffisjele webside fan English Heritage, de organisaasje dy't him ynset foar it behâld fan it Ingelske kultuergoedYnwennertallen fan alle Britske stêden út 'e folkstelling fan 2011Notes en References, op dizze sideEngland

Հադիս Բովանդակություն Անվանում և նշանակություն | Դասակարգում | Աղբյուրներ | Նավարկման ցանկ