Skip to content
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

Simplified clear screen command #1148

Open
wants to merge 2 commits into
base: main
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
10 changes: 3 additions & 7 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -3899,16 +3899,12 @@ def get_memory_alignment(in_bits: bool = False) -> int:
def clear_screen(tty: str = "") -> None:
"""Clear the screen."""
global gef
if not tty:
gdb.execute("shell clear -x")
return

# Since the tty can be closed at any time, a PermissionError exception can
# occur when `clear_screen` is called. We handle this scenario properly
try:
with open(tty, "wt") as f:
f.write("\x1b[H\x1b[J")
sys.stdout.write("\x1b[H\x1b[J")
Copy link
Owner Author

Choose a reason for hiding this comment

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

is tty even required 🤔 ?

except PermissionError:
# Since the tty can be closed at any time, a PermissionError exception can
# occur when `clear_screen` is called. We handle this scenario properly
gef.ui.redirect_fd = None
gef.config["context.redirect"] = ""
return
Expand Down
Loading