Skip to content

Conversation

afresquet
Copy link

@afresquet afresquet commented Apr 28, 2024

Fixes #1441 #1254

The real issue wasn't the missing Nushell class, but rather sys.stdout.write failing to make nushell run the command.

I've fixed that by running a subprocess, however it lacks access to any config/env that is set in the current session, it could be fixed by adding an -l flag to the command, but that will also run anything that run on login (like neofetch).

Still, also added a Nushell class with the relevant overrides.

What do you think @nvbn ? Anything that could be changed let me know, it's my first time writing Python so I'm sure there are things that could be done better

@afresquet afresquet marked this pull request as ready for review April 28, 2024 17:15
@afresquet
Copy link
Author

CC @scorphus

Hopefully it's okay to ping you as I see you've made the last release :)

@acvcleitao
Copy link

Just tested it on my machine. Nice work!

Comment on lines +13 to +25
def get_aliases(self):
aliases = {}
command = 'help aliases | select name expansion | each { |row| $row.name + " ; " + $row.expansion } | str join (char nl)'
proc = Popen(['nu', '-l', '-c', command], stdout=PIPE, stderr=DEVNULL)
if proc.stdout is None:
return aliases
alias_out = proc.stdout.read().decode('utf-8').strip()
for alias in alias_out.split('\n'):
split_alias = alias.split(" ; ")
if len(split_alias) == 2:
name, value = split_alias
aliases[name] = value
return aliases
Copy link

Choose a reason for hiding this comment

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

Would it be possible to get all the commands in nushell aswell using help commands in here?
help aliases only gets the actual aliases, i.e, stuff like alias vim = nvim.

Copy link
Author

Choose a reason for hiding this comment

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

good catch, I'll change that

Copy link

Choose a reason for hiding this comment

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

sweet, this will be awesome when its working merged!

@Dorsivan
Copy link

Any plans to merge this?

@JumpIn-Git
Copy link

this repo is dead, make a fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doesn't work in nushell (sees it as generic shell)

5 participants