Skip to content

REPL: show user loaded packages in the banner #58366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,17 @@ function banner(io::IO = stdout; short = false)
end
end

loaded_user_modules = filter(names(Main,imported=true)) do m
typeof(getfield(Main, m)) <: Module && m ∉ (:Base, :Core, :Main)
end
if isempty(loaded_user_modules)
loaded_modules_string = ""
else
# account for what has been printed before on this line
allowed_width = displaysize(io)[2] - 26
loaded_modules_string = rtruncate("Loaded packages: $(join(loaded_user_modules, ", "))", allowed_width)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if I put OmniPackage's direct and indirect dependencies in my startup.jl? Do you still like the outcome?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Good point. I think it's reasonable for this to just truncate with ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-05-09 at 11 29 51 AM

Note that Pkg and REPL are in this list because they were loaded as user packages via -ie "using REPL, Pkg" rather than the typical require_stdlib way.


commit_date = isempty(Base.GIT_VERSION_INFO.date_string) ? "" : " ($(split(Base.GIT_VERSION_INFO.date_string)[1]))"

if get(io, :color, false)::Bool
Expand All @@ -1756,7 +1767,7 @@ function banner(io::IO = stdout; short = false)
$(jl)| | | | | | |/ _` |$(tx) |
$(jl)| | |_| | | | (_| |$(tx) | Version $(VERSION)$(commit_date)
$(jl)_/ |\\__'_|_|_|\\__'_|$(tx) | $(commit_string)
$(jl)|__/$(tx) |
$(jl)|__/$(tx) | $(loaded_modules_string)

""")
end
Expand Down