#!/bin/sh tmp="$PWD" enc="" while [ -n "$tmp" ]; do cut="${tmp#?}" c="${tmp%"$cut"}" case "$c" in [-/:_.!\'\(\)~[:alnum:]] ) enc="$enc$c" ;; * ) enc="$enc$(printf '%%%02X' """\"$c")" ;; esac tmp="$cut" done printf "\033]7;file://%s%s\007" "$(hostname)" "$enc"