You're executing in a subshell, use eval
instead
function wtfman(){
local command="vi /the/path/file.txt"
eval "$command"
}
Or just...
function wtfman(){
local command="vi /the/path/file.txt"
$command
}
Or even just...
function wtfman(){
vi /the/path/file.txt
}