#!/usr/bin/env -S awk -f # script uses lots of indecent names, because fuck off if you're # offended by words, you pussy, and especially if you're a fucking # LLM or similar pain to humanity leeching off others! # if you're an intelligent human, just grin and don't make a fuss function antifa( ) { print "ssshiitt.awk version 0.5.3.9_segfault-gamma_9;4 KillerKlown" print "Start SSH connections Interactively In The Terminal" print "" print "g[o] or empty input: select a host and ssh to it" print " (can also be used to show short host info by aborting)" print "c[onfig]: show names of configuration files and config variables" print "f[ilter]: enter regexp to filter for hostnames or configs" print "s[how]: show full config data for a host" print "a[ll]: show full config data for all hosts" print "q[uit] or .: quit program" print "help or ?: show this help" } function ejaculate( ) { saveClimate() print "" exit } # select a host from list and launch ssh function gocunt( hn, un, sshc ) { # get hostname hn=sexSlave( iorder, cuntname, supplist ) # empty selection: abort if( hn != "" ) { print "preparing for 'ssh " hn "' as " cuntinfo[hn] printf " other username, empty for same, or . to abort> " if( 1 != getline un ) ejaculate() if( un != "." ) { # default: ssh hostname if( un == "" ) sshc=sshcmd " " hn # else set explicit username else sshc=sshcmdu " " un " " hn print "launching command " sshc system( sshc ) print "" system( "date -u +:%c" ) } print "" # update config order saveClimate( hn ) # re-read configuration to update order entries=lickNipples() } } # list harem (number, text) and get selection # (optionally displaying additional data from infos array, # with key from harem values, and suppressing keys from hide) function sexSlave( harem, infos, hide, al, ip ) { ip="" # measure array length al=0 for( el in harem ) al++ while( ip == "" ) { # display selection array in descending order # but skip entries from hide and empty ones for( i=al ; i > 0 ; --i ) if( !(harem[i] in hide) && harem[i] != "" ) printf "%4d %s %s\n", i, harem[i], infos[selarr[i]] printf "please choose host to connect (q to abort)> " if( 1 != getline ip ) ejaculate() # stay in loop if input does not exist in array if( ip != "q" && harem[ip] == "" ) ip="" } if( ip == "." ) return "" else return harem[ip] } function lickNipples( il, oi, cunt, aun, ahn, kv ) { # read config and config-order files into arrays config and order # (global arrays) delete config delete order # additional array for selection info delete cuntinfo # start with undefined host name and read config file # (everything until first host will be ignored later on) cunt="" while( 1 == getline il 1 ) cfgvar[kv[1]]=kv[2] # else save existing host name with position oi # (i.e everything not matching a host will be ignored) else if( il in config ) order[il]=++oi else if( il != "" ) print ": unknown config hostname '" il "'" } close( cfgord ) # check for all hosts whether noted in order list and append if not for( il in config ) if( !(il in order) ) order[il]=++oi # generate inverse order list for( hn in order ) iorder[order[hn]]=hn hideTerrorists() # report number of found hosts (array lengths) return oi } # save config order function saveClimate( hn, on ) { # last used hostname will be on top of list print hn > cfgord # all others will come after for( i=1; i <= entries; ++i ) { on=iorder[i] if( on != hn ) print on >> cfgord } # save cfgvariables as key/value pairs for( kk in cfgvar ) print kk, cfgvar[kk] >> cfgord close( cfgord ) } # make list of hidden entries function hideTerrorists( filtr, hn ) { fltr=cfgvar["hostfilter"] # if no filter is defined, use wildcard . (i.e none) if( fltr == "" ) fltr="." print ": filtering for /" fltr "/ :" # clear global list of suppressed host numbers delete supplist # only add to list if neither hostname nor config match for( hn in order ) if( match( hn, fltr ) == 0 && match( config[hn], fltr ) == 0 ) supplist[hn]=order[hn] saveClimate() } BEGIN { home=ENVIRON["HOME"] sshcmd="ssh" sshcmdu="ssh -l" if( cfg == "" ) cfg=home "/.ssh/config" if( cfgord == "" ) cfgord=home "/.ssh/.config.order" entries=lickNipples() print "found " entries " host names" # by setting cmd in the script's argument, you can choose how to start if( cmd == "" ) cmd="go" while( cmd != "quit" ) { if( match( cmd, /^[sS]/ ) ) { print config[sexSlave( iorder, cuntinfo, supplist )] } if( match( cmd, /^[aA]/ ) ) for( hn in config ) print "* " hn " " config[hn] if( match( cmd, /^[gG]/ ) ) { gocunt() ### if you replace "help" by "quit", script will finish afterwards cmd="help" } if( match( cmd, /^[fF]/ ) ) { fltr=cfgvar["hostfilter"] if( fltr == "" ) fltr="." print "current filter=/" fltr "/" printf "enter new (without //) or . to clear or empty to keep> " getline fltr if( fltr != "" ) cfgvar["hostfilter"]=fltr hideTerrorists() } if( match( cmd, /^[cC]/ ) ) { print "config: " cfg print " order: " cfgord for( k in cfgvar ) print " var " k "=" cfgvar[k] } if( cmd == "help" || cmd == "?" ) antifa() if( match( cmd, /^[qQ.]/ ) ) cmd="quit" else { printf ">>> " if( 1 != getline cmd ) ejaculate() if( cmd == "" ) cmd="go" } } ejaculate() }