Improved code readability
[sixth-3d-demos.git] / tools / open with IntelliJ IDEA
1 #!/bin/bash
2
3 # This script launches IntelliJ IDEA with the current project
4 # directory. The script is designed to be run by double-clicking it in
5 # the GNOME Nautilus file manager.
6
7 # First, we change the current working directory to the directory of
8 # the script.
9
10 # "${0%/*}" gives us the path of the script itself, without the
11 # script's filename.
12
13 # This command basically tells the system "change the current
14 # directory to the directory containing this script".
15
16 cd "${0%/*}"
17
18 # Then, we move up one directory level.
19 # The ".." tells the system to go to the parent directory of the current directory.
20 # This is done because we assume that the project directory is one level up from the script.
21 cd ..
22
23 # Now, we use the 'setsid' command to start a new session and run
24 # IntelliJ IDEA in the background. 'setsid' is a UNIX command that
25 # runs a program in a new session.
26
27 # The command 'idea .' opens IntelliJ IDEA with the current directory
28 # as the project directory.  The '&' at the end is a UNIX command that
29 # runs the process in the background.  The '> /dev/null' part tells
30 # the system to redirect all output (both stdout and stderr, denoted
31 # by '&') that would normally go to the terminal to go to /dev/null
32 # instead, which is a special file that discards all data written to
33 # it.
34
35 setsid idea . &>/dev/null &
36
37 # The 'disown' command is a shell built-in that removes a shell job
38 # from the shell's active list. Therefore, the shell will not send a
39 # SIGHUP to this particular job when the shell session is terminated.
40
41 # '-h' option specifies that if the shell receives a SIGHUP, it also
42 # doesn't send a SIGHUP to the job.
43
44 # '$!' is a shell special parameter that expands to the process ID of
45 # the most recent background job.
46 disown -h $!
47
48
49 sleep 2
50
51 # Finally, we use the 'exit' command to terminate the shell script.
52 # This command tells the system to close the terminal window after
53 # IntelliJ IDEA has been opened.
54 exit