Skip to content

Instantly share code, notes, and snippets.

View mohandseduA's full-sized avatar

mohandsedu mohandseduA

View GitHub Profile
@mohandseduA
mohandseduA / Argument Completer Register.md
Last active September 1, 2023 04:13
Registers an argument completer for a script block, sorts the completion file in descending order and removes it from temporary directory.

Argument Completer Register

Preview:
Register-ArgumentCompleter -Native -CommandName az -ScriptBlock {
    param($commandName, $wordToComplete, $cursorPosition)
    $completion_file = New-TemporaryFile
    $env:ARGCOMPLETE_USE_TEMPFILES = 1
    $env:_ARGCOMPLETE_STDOUT_FILENAME = $completion_file
    $env:COMP_LINE = $wordToComplete
    $env:COMP_POINT = $cursorPosition
#!/usr/bin/env python
import argparse
import heapq
def parse_args():
parser = argparse.ArgumentParser(description="Analyze bashstart log for speed.")
parser.add_argument('filename', help="often /tmp/bashstart.<PID>.log")
parser.add_argument('-n', default=20, help="number of results to show")
return parser.parse_args()