function smartenter -d "Running this doesn't make much sense. Bind it to ctrl-enter!" set __se_cmd (commandline -o) set __se_params (count $__se_cmd) set __se_inca 0 set __se_incb 0 set __se_didmatch 0 if [ $__se_params -eq 1 ] set __se_jobcmds (jobs -c) set __se_jobpids (jobs -p) for i in $__se_jobcmds set __se_inca (math $__se_inca+1) if [ $i = $__se_cmd ] for j in $__se_jobpids set __se_incb (math $__se_incb+1) if [ $__se_inca -eq $__se_incb ] set __se_didmatch 1 echo fg $j commandline -r "" end end end end if [ $__se_didmatch != 1 ] echo eval $__se_cmd kill -s WINCH %self commandline -r "" end else echo eval $__se_cmd kill -s WINCH %self commandline -r "" end end