This is pretty hackish, but it works...
- {l Code}: {l Select All Code}
bind <key> [ if $weaptog [weapon (weapslot $weapidxsmg); weaptog = 0] [weapon (weapslot $weapidxshotgun); weaptog = 1] ]
You'll just have to define
weaptog beforehand (autoexec would be ideal).
If there were a way to return your current weapon, this bind could be a lot less hackish :P
[EDIT]
You can get a bit fancy with this, which will return the name of the weapon that you have in your hand:
- {l Code}: {l Select All Code}
(getweap (weapslot -1) -1)
The best part is that it's <weap>name agnostic, meaning if the weapon's name is non-default, it will still return its base name (ie. 'shotgun'). Combine this with
hasweap, and you can make a small function that will only toggle if you have the weapon.