-2

Currently I need to access the folder in my desktop, and then a bin subfolder to reach ./pycharm.

So I want to automate all of:

cd Desktop
cd pycharm-community-2021.3.1
cd bin
./pycharm.sh

to

pycharm

I would like to ease the process by just inputting 'pycharm' in the terminal and have it launch. I'm aware Linux is incredible for such things - I just forgot how its called and how its done so. If someone could point me in the right direction. I would appreciate.

4
  • Have you added the full path to it to your PATH environment variable? For bash, you want to add the line export PATH="${PATH}:~/Desktop/pycharm-community-2021.3.1/bin" to the end of the file .bashrc (or .profile, or whichever shell startup file is appropriae for your shell of choice). (The export is also not really needed in this case, but get in the habit of being explicit now to avoid frustrating problems later...)
    – C. M.
    Commented Jul 26, 2021 at 5:37
  • You could also, from within the ~/Desktop/pycharm-community-2021.3.1/bin direcory, create a symlink, ln -s pycharm.sh pycharm, which will enable you to simply type pycharm without the leading ./ or .py extension.
    – C. M.
    Commented Jul 26, 2021 at 5:39
  • Hi C.M, for the first comment as it is the most relevant, I did not fully understand, could you elaborate? I do admit of being a linux newbie.. Commented Jul 27, 2021 at 3:01
  • I would suggest then that you find an online introduction/tutorial to working with Unix/Linux and the various shell command lines. That is far outside the scope and purpose of this site.
    – C. M.
    Commented Jul 27, 2021 at 3:56

2 Answers 2

0

An alias is a good fit for this use case:

alias pycharm="~/Desktop/pycharm-community-2021.3.1/bin/pycharm.sh"

Add this to your shell's customization file. As an example, that's ~/.bashrc for the bash shell. You can then run pycharm as intended.

6
  • Tried this, wont launch and terminal wont recognize the alias for some reason.. Commented Jul 27, 2021 at 3:00
  • @ThomasReiner If you added the line to the bashrc file, you need to start a new shell instance so that it can read the bashrc file. If you want to do this on the current shell instance, just run the command as alias pycharm..... ; pycharm.
    – Haxiel
    Commented Jul 27, 2021 at 3:07
  • New terminal wont work either. 'alias pycharm' returns 'command not found'. I'm running kali. Commented Jul 27, 2021 at 3:09
  • An alias has several problems: (1) Various shell syntax is not always easily portable between different shells. (2) It will not get sourced if called from a non-interactive shell. (3) It becomes cumbersome to maintain should you want to restructure your file system. (4) It requires (re)loading in to the current shell and/or all terminal sessions.
    – C. M.
    Commented Jul 27, 2021 at 4:03
  • @ThomasReiner Maybe you're running a different shell. In any case, Kali isn't a suitable distro for a newcomer to Linux. There's already a learning curve for Linux, and Kali would just make it more difficult.
    – Haxiel
    Commented Jul 27, 2021 at 4:05
0

As suggested by C.M, created a symlink:

from within the ~/Desktop/pycharm-community-2021.3.1/bin directory create a symlink, ln -s pycharm.sh pycharm, which will enable you to simply type pycharm without the leading ./ or .py extension.

Then copied the symlink to Desktop.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .