Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Feature request: set extension for =( ) created file



On Sep 24,  7:51pm, Sebastian Gniazdowski wrote:
}
} vim =( git -C /home/user/github/proj.git cat-file blob 1e08920 )
} 
} One will not get proper syntax highlighting because the file will be
} e.g.: /tmp/zshoF8Hlc, without extension like .java.

How about this?

    vimtmp () {
      local filetype="$(file $1)"
      case "$filetype" in
      (*[Jj]ava*) filetype=java;;
      (*) : etc.
      esac
      vim -c ":set filetype=$filetype" $1
    }

    vimtmp =( git -C /home/user/github/proj.git cat-file blob 1e08920 )

You can extend this with a cached mapping of "file" output to file types
and something to prompt/update the cache on unrecognized output.



Messages sorted by: Reverse Date, Date, Thread, Author