dotfiles/.config/ipython/profile_default/starup/magic_ps.py
2024-11-20 14:27:00 +00:00

10 lines
348 B
Python

from IPython.core.magic import register_line_magic
@register_line_magic
def ps(cmd):
output = get_ipython().getoutput(f"powershell -Command {cmd}")
# If no variable is assigned to the output, print it
if get_ipython().last_execution_result is None:
print("\n".join(output))
else:
return "\n".join(output)