I very (very!) often do this routine in my daily work:
$ j7 # (alias for Julia version 1.7)
julia>
julia> ] activate .
(or similarly) (@v1.8) pkg> activate .
Activating project at `~/MyMWE_WorkingPath`
julia> using Revise ; using RRSP # RRSP is my working module
I would like to have an alias for doing this routine quicker and easilier. I do it at the very least ten times a week and will do it for months more.
Ideally, I would do something like, j7RRSP which is an alias for:
alias j7RRSP='julia > ]activate . ; using Revise ; using RRSP'
This is incorrect and I don't know how to do it well! I know alias for executing julia files are possible :
alias j7jl='julia somefiles.jl'
In my case, I am activating a project then using two packages, Revise, which is standard, then RRSP that I created.
CodePudding user response:
Here is one solution:
alias j7RRSP='julia --project=. -e "using Revise, RRSP" -i'
Flags:
--project=.
: start with the project in the current directory directly instead of using]activate .
,-e "..."
: evaluate the code...
,-i
: ask for an interactive session, this is needed since otherwise, due to combining with-e
, the process exits after evaluating the code.
CodePudding user response:
Another solution is using a function that works exactly like an alias, but with a much saner syntax and capabilities:
j7RRSP() {
julia --project=. -e "using Revise, RRSP" -i "$@"
}
As a one-line:
j7RRSP(){ julia --project=. -e "using Revise, RRSP" -i "$@";}