-
-
Save samueldr/6b0bc554f14545ec6e00ad95c3d34058 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "open3" | |
require "pp" | |
name = ARGV.shift | |
search = "^/bin/#{name}$" | |
cmd = ["nix-locate", "-1wr", search] | |
stdin, stdout, stderr, wait_thr = Open3.popen3(*cmd) | |
out = (stdout.gets(nil) or "").split("\n") | |
stdout.close | |
attrs = out | |
.select { |s| s[0] != "(" } | |
.map{ |s| s.sub(/\.out$/, "") } | |
.sort | |
STDERR.puts "#{name}: command not found" | |
if out.length.positive? then | |
STDERR.puts "" | |
STDERR.puts " → #{name} is provided by:" | |
attrs.each do |attr| | |
STDERR.puts " * #{attr}" | |
end | |
end | |
exit 127 | |
# vim: ft=ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command_not_found_handle () | |
{ | |
if ( type -t command-not-found > /dev/null ); then | |
command-not-found "$@"; | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment