title: determine file type of a file without extension
body: <p>I want to use <code>pygmentize</code> to highlight some script files (python/bash/...) without extension. But <code>pygmentize</code> requires me to specify the lexer using <code>-l</code>. It does not automatically identify the file type from the content.</p>
  
  <p>I have the following options at hand, but none of them work now:</p>
  
  <ol>
  <li>use <code>file -b --mime-type</code>. But this command output <code>x-python</code> and <code>x-shellscript</code> instead of <code>python</code> and <code>bash</code> and I don't know the rules</li>
  <li>use <code>vim -e -c 'echo &amp;ft|q' the_file</code>. For any file with or without file extension, vim has a mechanism to guess the file type. But it doesn't work. Since the output goes to the vim window and disappears after <code>q</code>. </li>
  </ol>
  
  <p>What can I do?</p>
  
  <hr>
  
  <p>@Samborski's method works fine in normal case but it does not work in python <code>subprocess.check_output</code> since the pts is not allocated. If you use <code>nvim</code>, you can use this more straightforward way:</p>
  
  <pre><code>HOME=_ nvim --headless -es file &lt;&lt;EOF
  call writefile([&amp;ft], "/dev/stdout")
  EOF
  </code></pre>