1

In home I have a project folder nomse/bin/main.dart. in terminal. If I use command like,

dart nomse/bin/main.dart 

I can run my app.

UPDATE-1: I need to add path to .profile so I can run my app without typing a path on terminal. (I know how to add path to .profile), just bear with me.

All I need is that (as an example because I don't know how to do it) I need to add the nomse/bin/main.dart in .profile and run like dart nomse.

I need to give a name to my path like nomse. So I can run like dart nomse. How do I do that?

UPDATE-2:

in .profile I add path as 
PATH="$HOME/.nomse/bin/main.dart:${PATH}"
export PATH

how can I give a name to my path so I can run on terminal like?

dart nomse
Nick
  • 113

2 Answers2

3

It is not clear from your post, whether you want to add PATH to the executable dart or to the parameter main.dart.

For the first one, just export the PATH.

For the later, do you want to execute like: dartparamter should get expanded to dart $HOME/.paramter/bin/main.dart? In that case you can write a small macro/function in your ~/.bashrc:

function mydart()
{
   nomse="$1"
   /path/to/dart "$HOME/.$nomse/bin/main.dart
}

Then on terminal call mydart nomse.

2

Suppose your command dart lies in a folder /path/to/folder/containing/dart/command, then just add the following line to the bottom of your ~/.profile:

dir=/path/to/folder/containing/dart/command
if [ -d "$dir" ] ; then
  PATH="$PATH:$dir"
fi

In addition to this (or alternatively) you can add the following line to your ~/.bashrc:

export PATH="$PATH:/path/to/folder/containing/dart/command"

For your current session, you can run this command.

This will tell the system where the executable dart lies.Now you can call

dart /path/to/main.dart

from anywhere.

user5325
  • 448