Instead of being required to open Putty when you want to connect to a SSH host, wouldn’t it be rather handy to display the list in Rofi?

The script shown below does just that, and it therefore provides a very quick way to connect to the desired SSH host. All you need to change is the config directory containing the putty session files, referenced on line 4.

#!/bin/bash

OLD_IFS="$IFS"
IFS=$'\n' win_array=($(ls --ignore="Default*" /home/karmst/.config/putty/sessions))
IFS="$OLD_IFS"

win_length=${#win_array[@]}
space=" "

for i in "${!win_array[@]}"; do
  win_array[$i]=${win_array[$i]//"%20"/" "}
  win_array[$i]=${win_array[$i]//"%28"/"("}
  win_array[$i]=${win_array[$i]//"%29"/")"}
  win_array[$i]="$((i+1))"$space${win_array[$i]//"%29"/")"}
done

choice=$(printf '%s\n' "${win_array[@]}" | rofi -dmenu -auto-select -i -p "Putty Session") "$@" || exit

choice1=$(echo $choice | sed 's/\([0-9]*\) \(.\+\)$/\2/')

putty -load "$choice1"

exit 0