Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Fix bug that causes status line to be empty if Unix username has spaces #84

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Fix bug that causes status line to be empty if Unix username has spaces #84

wants to merge 3 commits into from

Conversation

joschnitzbauer
Copy link

The current implementation for extracting the current working directory (cwd) fails for Unix when the username has a space. This causes the cwd string to be empty, which leads to a completely empty status line.

Specifically, awk retrieves the 4th field from the lsof output, but when the username has a space, cwd is actually the 5th, because of the additional whitespace.

The submitted patch circumvents this by using the -F option for lsof so that columns are returned as rows for increased machine-readability. The correct field is filtered by process id (-p ${pid}) and field identifier (-d cwd), where the -a option ensures the logical and of these filters. The output of lsof is then grepped to get the field with identifier n (name) as the first character. This identifier is finally removed with cut, so that the remaining string is the current working directory.

Tested with Hyper 2.0.0 on MacOS High Sierra 10.13.6

@joschnitzbauer joschnitzbauer changed the title Fix/nix username w space Fix bug that causes status line to be empty if Unix username has spaces Sep 1, 2018
j-f1 added a commit to j-f1/forked-hyper-statusline that referenced this pull request Sep 3, 2018
@j-f1
Copy link

j-f1 commented Sep 3, 2018

I’ve published this to @j-f/hyper-statusline. You can swap hyper-statusline with @j-f/hyper-statusline in your config to switch. Feel free to contribute!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants