Skip to content

Commit 304d500

Browse files
committed
feat(tty/find): add npm and pip channels to television
Add fuzzy search channels for installed npm and pip packages with preview and homepage actions.
1 parent 3227247 commit 304d500

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

home/tty/find/misc.nix

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,46 @@
8888
mode = "execute";
8989
};
9090
};
91+
92+
npm = {
93+
metadata = {
94+
name = "npm";
95+
description = "Search and preview installed npm packages";
96+
requirements = ["npm" "jq"];
97+
};
98+
source.command = "npm list -g --depth=0 --json 2>/dev/null | jq -r '.dependencies // {} | keys[]' | sort";
99+
preview = {
100+
command = ''
101+
npm view '{0}' --json 2>/dev/null | jq -r '"\u001b[1;36m# \(.name):\(.version)\u001b[0m\n\(.description // "")\n\n\u001b[1mHomepage:\u001b[0m \(.homepage // "N/A")\n\u001b[1mLicense:\u001b[0m \(.license // "N/A")\n\u001b[1mKeywords:\u001b[0m \((.keywords // []) | join(", "))"'
102+
'';
103+
ansi = true;
104+
};
105+
keybindings.enter = "actions:open";
106+
actions.open = {
107+
description = "Open the selected package's homepage";
108+
command = "npm view '{0}' homepage | xargs open";
109+
mode = "execute";
110+
};
111+
};
112+
113+
pip = {
114+
metadata = {
115+
name = "pip";
116+
description = "Search and preview installed pip packages";
117+
requirements = ["pip" "jq"];
118+
};
119+
source.command = "pip list --format=json 2>/dev/null | jq -r '.[].name' | sort";
120+
preview = {
121+
command = "pip show '{0}'";
122+
ansi = false;
123+
};
124+
keybindings.enter = "actions:open";
125+
actions.open = {
126+
description = "Open the selected package's homepage";
127+
command = "pip show '{0}' | grep 'Home-page:' | awk '{print $2}' | xargs open";
128+
mode = "execute";
129+
};
130+
};
91131
};
92132
};
93133
}

0 commit comments

Comments
 (0)