I don't think that's quite what you want unless you want to have output of:
Hello/Hello/Hello/-
Hello/Hello/Hello
Assuming you actually just want to allow breaks at the slashes, you could instead set the \hyphenchar for the font to /. There are two gotchas: \hyphenchar is global. If you set it in a group, it will still apply outside of the group and you could also inadvertently have something typeset like:
Something ridicu/
lously absurdly
prolix
The second problem is the easier one to solve and is built into LaTeX's kernel. We can use \language\l@nohyphenation to turn off all hyphenation.¹
The first problem is a bit trickier. What we'll do is save the current hyphen character and use \aftergroup to restore it when the current group ends. Putting all of this together to give us our specialized version of \ttfamily, we can do:
\makeatletter % ❶
\NewDocumentCommand{\mytt}{}{% ❷
\ttfamily
\language\l@nohyphenation
\xdef\@restorehypenchar{% ❸
\hyphenchar\the\font\the\hyphenchar\font
}%
\aftergroup\@restorehyphenchar
\hyphenchar\font`/\relax
}
\makeatother
Note that we need access to private LaTeX commands ❶. And if you're stuck using an outdated LaTeX you can replace the line labeled ❷ with:
\newcommand{\mytt}{
We use \xdef at ❸ because we need to expand the contents of the definition (the resulting definition will be something akin to \hyphenchar \OT1/cmtt/m/n/10 -1) and it must be global since it's going to be expanded after the current group is completed.
You can then use \mytt in place of the \ttfamily in your example.
This is a little fragile. If you do something like
{\mytt {\mytt foo}}
you won't get the original hyphenchar for typewriter type back when you exit since the inner \mytt will overwrite the outer \mytt's definition of \@restorehyphenchar.
- This, in fact, is how hyphenation is suppressed in verbatim mode.
\slashmacro? – Mico Aug 29 '21 at 04:28