Skip to content

Instantly share code, notes, and snippets.

@jordansissel
Last active November 15, 2025 04:50
Show Gist options
  • Select an option

  • Save jordansissel/69fde20cae1f616f5bd7d8af76ef750d to your computer and use it in GitHub Desktop.

Select an option

Save jordansissel/69fde20cae1f616f5bd7d8af76ef750d to your computer and use it in GitHub Desktop.
Command line fun

Grep Ruby's NEWS/NEWS.md file for text and show me what version it's mentioned in:

% git tag | grep '^v[123]_[0-9]_0$' | xargs -n1 sh -c 'printf "$1:NEWS.md\n$1:NEWS\n" | git cat-file --batch | grep -i "Array.filter" | sed -e "s@^@$1: @"' -
v2_6_0:     * Array#filter is a new alias for Array#select. [Feature #13784]
v2_6_0:     * Array#filter! is a new alias for Array#select!. [Feature #13784]

Run a command with the same environment values as another process:

# Run a command with pid 1598748's environment variables:
ruby -0ne 'BEGIN { command = ARGV[1..-1]; ARGV.replace([ARGV.first]) }; name, value = $_.chomp.split("=", 2); ENV[name] = value; END { system(*command) }' /proc/1598748/environ dbus-run-session -- gnome-shell --nested --wayland
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment