Coder Social home page Coder Social logo

uxy's People

Contributors

0xflotus avatar jdidion avatar laodzu avatar mdhowle avatar sustrik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uxy's Issues

Package manager support

This tool is awesome! Are you thinking of adding package management support so I can get the latest updates?

"uxy ps" is confused by leading spaces

On my system (Ubuntu 18.04), the ps command prints leading spaces for some PIDs because the PID field is right-justified.

$ ps
  PID TTY          TIME CMD
 7269 pts/7    00:00:01 bash
12455 pts/7    00:00:00 ps
$ uxy ps
PID TTY TIME CMD
    7269 pts/7 "00:00:01 bash"
12459 pts/7 00:00:00 uxy
12460 pts/7 00:00:00 ps
$ uxy ps | uxy align
PID   TTY   TIME            CMD
7269  pts/7 "00:00:01 bash"
12509 pts/7 00:00:00        uxy
12510 pts/7 00:00:00        uxy
12511 pts/7 00:00:00        ps
$ 

Users and groups with spaces aren't handled properly

I'm in an environment where groups with spaces are common. The regular expression that extracts the output of ls cannot handle this properly. Since there are no delimiters for user and group names, it would not be possible to get the correct user and group.

For example, this is the output with spaces in the user and group names: (users: howlem and "test user ignore" and groups: "domain users")

TYPE PERMISSIONS LINKS OWNER      GROUP      SIZE         TIME                                  NAME 
d    rwxr-xr-x   4     howlem     domain     users        "4096 2019-05-23 14:17:07.493736735"  "-0400 debian" 
-    rw-r--r--   1     howlem     domain     users        "12837 2019-05-23 11:49:51.750633915" "-0400 README.md" 
-    rw-r--r--   1     test       user       ignore       "domain users     0"                  "2019-05-23 15:28:01.361719083 -0400 test" 
-    rw-r--r--   1     howlem     domain     users        "0 2019-05-23 15:49:04.809507672"     "-0400 test2" 
-    rw-r--r--   1     howlem     domain     users        "853 2019-05-24 10:43:18.835875117"   "-0400 test.py" 
-    rwxr-xr-x   1     howlem     domain     users        "21838 2019-05-28 10:24:17.890430740" "-0400 uxy" 

I wrote a quick implementation of ls. It does lose the extra ls arguments and the date/time format isn't the same.

import datetime
import os
import pwd
import grp

def uxy_cmd_ls(args, uargs):
  uargs =  uargs[0] if uargs else "."
  content = os.listdir(uargs)
  fmt = Format("TYPE PERMISSIONS LINKS OWNER      GROUP      SIZE         TIME                                  NAME") 
  writeout(fmt.render())

  for entry in content:
      fields = []
      fstats = os.stat(os.path.join(uargs, entry))
      mode = stat.filemode(fstats.st_mode)
      fields.append(mode[0])
      fields.append(mode[1:])
      fields.append(str(fstats.st_nlink))

      uid, gid = (fstats.st_uid, fstats.st_gid)
      try:
        user = pwd.getpwuid(uid).pw_name
      except KeyError:
        user = str(uid)
      
      fields.append(encode_field(user))

      try:
        group = grp.getgrgid(gid).gr_name
      except KeyError:
        group = str(gid)
      fields.append(encode_field(group))
    
      fields.append(str(fstats.st_size))
      fields.append(encode_field(datetime.datetime.fromtimestamp(fstats.st_mtime).isoformat()))
      fields.append(encode_field(entry))
      writeout(fmt.render(fields))
`

Fix arguments to ls and ps on Mac

This project has incredible potential but having some setup issues. i tried cloning the repo and putting uxy on my PATH (Mac OS) but seeing some issues:

$ uxy ls
TYPE PERMISSIONS LINKS OWNER      GROUP      SIZE         TIME                                  NAME
ls: illegal option -- N
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
$ uxy ps
PID      TTY      TIME       CMD
ps: illegal option -- -
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
          [-g grp[,grp...]] [-u [uid,uid...]]
          [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
       ps [-L]

uxy ls doesn't handle file names with spaces

If uxy ls encounters a file with a space in its name, it ignores the portion of the file name after the space.

I haven't checked other funny characters (for example, it's legal to have a newline in a filename).

On my system, Ubuntu 18.04:

$ ls -l
total 28
-rw-r--r-- 1 kst kst  8585 May 20 11:18 README.md
-rwxr-xr-x 1 kst kst 13522 May 20 11:18 uxy
$ uxy ls
TYPE PERMISSIONS LINKS OWNER      GROUP      SIZE         TIME                                  NAME
-    rw-r--r--   1     kst        kst        8585         "2019-05-20 11:18:33.459647439 -0700" README.md
-    rwxr-xr-x   1     kst        kst        13522        "2019-05-20 11:18:33.459647439 -0700" uxy
$ touch 'foo bar'
$ uxy ls
TYPE PERMISSIONS LINKS OWNER      GROUP      SIZE         TIME                                  NAME
-    rw-r--r--   1     kst        kst        8585         "2019-05-20 11:18:33.459647439 -0700" README.md
-    rw-r--r--   1     kst        kst        0            "2019-05-20 11:24:36.350283775 -0700" foo
-    rwxr-xr-x   1     kst        kst        13522        "2019-05-20 11:18:33.459647439 -0700" uxy
$

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.