Disable wrapping in Psql output

后端 未结 5 1456
猫巷女王i
猫巷女王i 2021-02-06 21:43

When using Psql in Linux, if the result of my SQL query contains many columns or long strings of data, it will wrap the initial view and only once I scroll to the side will it s

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 22:22

    less's -F or -S flag will causes \d some_table to not show any output in some cases.

    -F or --quit-if-one-screen
        Causes less to automatically exit if the entire file can be 
        displayed on the first screen.
    
    -S or --chop-long-lines
        Causes lines longer than the screen width to be chopped rather than folded. 
        That is, the portion of a long line that does not fit in the screen width is 
        not shown. The default is to fold long lines; that is, display the remainder 
        on the next line.
    

    Use them like this:

    PAGER="less -S" psql
    

    Seems safer at the inconvenience of having to manually exit less.

提交回复
热议问题