summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Murphy <tylerm@tylerm.dev>2023-04-28 15:48:55 -0400
committerTyler Murphy <tylerm@tylerm.dev>2023-04-28 15:48:55 -0400
commit4403e7edc2743ef6275e1adb82758bd475ac6602 (patch)
treeb735ef7ab76cc91205d85c22a3bdddff373de909
parentadd tail (diff)
downloadlazysphere-4403e7edc2743ef6275e1adb82758bd475ac6602.tar.gz
lazysphere-4403e7edc2743ef6275e1adb82758bd475ac6602.tar.bz2
lazysphere-4403e7edc2743ef6275e1adb82758bd475ac6602.zip
ls tty fix
-rw-r--r--src/commands/ls.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/commands/ls.c b/src/commands/ls.c
index 1c8384a..d31c143 100644
--- a/src/commands/ls.c
+++ b/src/commands/ls.c
@@ -166,10 +166,13 @@ static char* get_file_color(struct FileInfo* info) {
}
static void list_files(struct FileInfo* files, int file_len, struct FileListInfo info, struct Flags* flags, const char* dir_path) {
-
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
+ if (!isatty(1)) {
+ flags->one_column = true;
+ }
+
char* color;
const int column_width = info.max_name + 1;
const int row_count = w.ws_col / column_width;
@@ -371,7 +374,6 @@ COMMAND(ls) {
flags.hide_dot = false;
flags.one_column = false;
flags.recurse = false;
-
int start = 0;
for (int i = 0; i < argc; i++) {
if (!prefix("-", argv[i])) break;