Giter Site home page Giter Site logo

pls-rs / pls Goto Github PK

View Code? Open in Web Editor NEW
654.0 654.0 20.0 10.47 MB

`pls` is a prettier and powerful `ls(1)` for the pros.

Home Page: https://pls.cli.rs/

License: GNU General Public License v3.0

Rust 98.07% Just 1.16% JavaScript 0.03% Shell 0.75%
ansi cli ls posix rust terminal

pls's People

Contributors

dependabot[bot] avatar dhruvkb avatar kianmeng 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

pls's Issues

pls doesn't work even if I set PYTHONIOENCODING

Description

Installed pls via the pip --user install.

Specifically:

pip install --user --upgrade pls

When I run it complains about You may need to add PYTHONIOENCODING=utf-8 to your environment and even if I do that, it doesn't work.

Reproduction

using zsh

  1. export PYTHONIOENCODING=utf8
  2. pls (gives error)
  3. export PYTHONIOENCODING=utf-8
  4. pls (gives error)
  5. export PYTHONIOENCODING="utf-8"
  6. pls (gives error)
  7. export PYTHONIOENCODING="utf8"
  8. pls (gives error)

Expectation

pls to run without error

Environment

  • Device: Desktop
  • OS: Fedora 34
  • Browser: N/A
  • Version: pls 1.11.1
  • Other info:

Additional context

the actual commands/errors:

$ export PYTHONIOENCODING=utf-8
$ pls
Traceback (most recent call last):
File "/home/ermesa/.local/bin/pls", line 8, in
sys.exit(main())
File "/home/ermesa/.local/lib/python3.9/site-packages/pls/main.py", line 31, in main
write_output(node_list)
File "/home/ermesa/.local/lib/python3.9/site-packages/pls/table/table.py", line 116, in write_output
console.print(table)
File "/home/ermesa/.local/lib/python3.9/site-packages/rich/console.py", line 1637, in print
self._buffer.extend(new_segments)
File "/home/ermesa/.local/lib/python3.9/site-packages/rich/console.py", line 837, in exit
self._exit_buffer()
File "/home/ermesa/.local/lib/python3.9/site-packages/rich/console.py", line 795, in _exit_buffer
self._check_buffer()
File "/home/ermesa/.local/lib/python3.9/site-packages/rich/console.py", line 1929, in _check_buffer
self.file.write(text)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udccf' in position 99: surrogates not allowed
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

Error when running in folders like /etc

First of all congratulations for the excellent work.

Problem

When I run the pls command in a folder like /etc or /dev I'm getting this error.

Traceback (most recent call last):
  File "/home/aeagiraldelli/.local/bin/pls", line 8, in <module>
    sys.exit(main())
  File "/home/aeagiraldelli/.local/lib/python3.8/site-packages/pls/main.py", line 16, in main
    nodes = read_input()
  File "/home/aeagiraldelli/.local/lib/python3.8/site-packages/pls/fs/list.py", line 82, in read_input
    all_nodes.sort(key=sort_key, reverse=args.sort == SortOrder.DESC)
  File "/home/aeagiraldelli/.local/lib/python3.8/site-packages/pls/fs/list.py", line 31, in sort_key
    prefix = "0" if node.node_type == NodeType.DIR else "1"
  File "/usr/lib/python3.8/functools.py", line 967, in __get__
    val = self.func(instance)
  File "/home/aeagiraldelli/.local/lib/python3.8/site-packages/pls/models/node.py", line 93, in node_type
    self.dest_node = Node(name=link_path, path=link)
TypeError: __init__() missing 1 required positional argument: 'state'

Steps to reproduce

open a terminal

cd /etc
pls --details

Extra information

I'm using

  • Linux Mint 20.3
  • zsh 5.8

I installed pls using pipx

pipx list

venvs are in /home/aeagiraldelli/.local/pipx/venvs
apps are exposed on your $PATH at /home/aeagiraldelli/.local/bin
   package glances 3.2.4.2, installed using Python 3.8.10
    - glances
   package pls 1.8.0, installed using Python 3.8.10
    - pls

OSError in `is_dir` is not catched

Description

is_dir can throw an OSError, which is not catched.

Traceback (most recent call last):
  File "/home/grzegorzmilka/.local/bin/pls", line 8, in <module>
    sys.exit(main())
  File "/home/grzegorzmilka/.local/pipx/venvs/pls/lib/python3.9/site-packages/pls/main.py", line 102, in main
    node_map, node_list = read_input()
  File "/home/grzegorzmilka/.local/pipx/venvs/pls/lib/python3.9/site-packages/pls/fs/list.py", line 72, in read_input
    node_map = {
  File "/home/grzegorzmilka/.local/pipx/venvs/pls/lib/python3.9/site-packages/pls/fs/list.py", line 75, in <dictcomp>
    if (parsed_node := parse_node(parent_path, node))
  File "/home/grzegorzmilka/.local/pipx/venvs/pls/lib/python3.9/site-packages/pls/fs/list.py", line 38, in parse_node
    if node_path.is_dir():
  File "/usr/lib/python3.9/pathlib.py", line 1439, in is_dir
    return S_ISDIR(self.stat().st_mode)
  File "/usr/lib/python3.9/pathlib.py", line 1232, in stat
    return self._accessor.stat(self)
OSError: [Errno 126] Required key not available: '/home/grzegorzmilka/target'

Reproduction

I don't know how to reproduce this. target is a symbolic link to a directory, which is inaccessible at the time of the call.

Expectation

No error is thrown. Maybe the directory doesn't get any special symbol or is marked with red.

Environment

  • Device: Desktop
  • OS: Debian
  • Version: 4.0.1

Missing configuration documentation

Description

Currently, there is not much documentation about the configuration file options, especially the app_const and entry_const options. Having a single page documenting all the options in the .pls.yaml file would be extremely helpful.

In that vein, the link to https://pls-rs.github.io/pls/guides/conf/ is broken. The page does not exist, and results in an Error 404. It is linked from https://pls-rs.github.io/pls/guides/specs/#configuration.

I have omitted the other sections in the issue template as they do not pertain to this bug/issue.

List contents of multiple directories in one command

Description

pls * or pls <dir1> <dir2> currently shows the help and an error. It would be great if pls could show the contents of multiple directories in one command like ls can.

Implementation

  • πŸ™‹ I would be interested in implementing this feature.

Note pipx installation method in documentation

I usually use pipx to install command-line utilities that happen to be written in Python but are meant to be installed globally.

pls installs well with pipx and I'd recommend noting this in the installation instructions.

rich-cli, poetry, nox, and pyxtermjs all mention pipx installation instructions in their documentation for example.

Pipx Uninstall Instruction Incorrect

Hi,

Really minor issue regarding the instructions for uninstalling from pipx in getting started.

Instructions show pipx uninstall peotry instead of pls.

Screen Shot 2022-03-06 at 3 48 24 pm

Really enjoying pls! Great job!

BTW Found out about pls via the Python Bytes podcast (episode 272) - also broadcast on YT.

Thanks
Michael

Error when no results

Description

When running pls with -d option (detailed view) and when there are no results (empty directory, or no files matching the regex), I get the following error :

thread 'main' panicked at src/output/table.rs:76:29:
range end index 1 out of range for slice of length 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fish: Job 1, 'pls -d std --only="^\."' terminated by signal SIGABRT (Abort)

Environment

pls specifications:

  • Version: 0.0.1-beta.4

Device specifications:

  • Operating system: macOS
  • Version: 14.1
  • Other info: fish shell

"pls" crashes if run with a non-existent directory name

Description

If I run pls something, and something is not a directory, it crashes.

Reproduction

  1. pls something, where something does not exist
  2. See error.

Expectation

I expected to see a concise error message, similar to the one ls prints, e.g.:

ybxh061@C02YD4UEJG5H ~ % ls something
ls: something: No such file or directory

Screenshots

ybxh061@C02YD4UEJG5H ~ % pls something
Traceback (most recent call last):
  File "/Users/ybxh061/.local/bin/pls", line 8, in <module>
    sys.exit(main())
  File "/Users/ybxh061/.local/pipx/venvs/pls/lib/python3.10/site-packages/pls/main.py", line 17, in main
    globals.state.parse_args(None)
  File "/Users/ybxh061/.local/pipx/venvs/pls/lib/python3.10/site-packages/pls/globals.py", line 63, in parse_args
    parser.parse_args(argv, namespace=self)
  File "/usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/argparse.py", line 1825, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/argparse.py", line 1858, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/argparse.py", line 2070, in _parse_known_args
    stop_index = consume_positionals(start_index)
  File "/usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/argparse.py", line 2026, in consume_positionals
    take_action(action, args)
  File "/usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/argparse.py", line 1919, in take_action
    argument_values = self._get_values(action, argument_strings)
  File "/usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/argparse.py", line 2450, in _get_values
    value = self._get_value(action, arg_string)
  File "/usr/local/Cellar/[email protected]/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/argparse.py", line 2483, in _get_value
    result = type_func(arg_string)
  File "/Users/ybxh061/.local/pipx/venvs/pls/lib/python3.10/site-packages/pls/arg_parser.py", line 49, in directory
    raise ExecException(f"`directory` arg should be a valid directory: {path_str}")
pls.exceptions.ExecException: `directory` arg should be a valid directory: something

Environment

  • Device: Macbook Pro
  • OS: Mac OS X Catalina (10.15.7)
  • Version: 2.0.0
  • Other info:

Additional context

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

Traps on out-of-tree absolute symlinks

The following two commands make pls trapped:

$ mkdir -p /tmp/dir/qq
$ ln -s /tmp/dir/qq pp
$ pls
Traceback (most recent call last):
  File "/home/george/venv/_pls/bin/pls", line 8, in <module>
    sys.exit(main())
  File "/home/george/venv/_pls/lib64/python3/site-packages/pls/main.py", line 16, in main
    node_map, node_list = read_input()
  File "/home/george/venv/_pls/lib64/python3/site-packages/pls/fs/list.py", line 82, in read_input
    node_list.sort(key=sort_key, reverse=args.sort.endswith("-"))
  File "/home/george/venv/_pls/lib64/python3/site-packages/pls/fs/list.py", line 26, in sort_key
    key = node.sort_keys[args.sort.rstrip("-")]
  File "/usr/lib64/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/george/venv/_pls/lib64/python3/site-packages/pls/models/node.py", line 207, in sort_keys
    "type": self.type_char,
  File "/usr/lib64/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/george/venv/_pls/lib64/python3/site-packages/pls/models/mixins/type.py", line 50, in type_char
    return type_char_map[self.node_type]
  File "/usr/lib64/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/george/venv/_pls/lib64/python3/site-packages/pls/models/mixins/type.py", line 41, in node_type
    self.populate_dest()
  File "/home/george/venv/_pls/lib64/python3/site-packages/pls/models/mixins/type.py", line 69, in populate_dest
    self.dest_node = self.__class__(name=link_path, path=link)
  File "/home/george/venv/_pls/lib64/python3/site-packages/pls/models/mixins/git.py", line 28, in __init__
    self.path_wrt_git = self.path.relative_to(state.git_root)
  File "/usr/lib64/python3.10/pathlib.py", line 816, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: '/tmp/dir/qq' is not in the subpath of '/home/george' OR one path is relative and the other is absolute.

Error when listing files on Windows

Description

When I run pls on Windows (for a certain directory), I get a stack trace.

Reproduction

  1. Running PowerShell as an administrator, install gsudo, specifically via chocolatey:
    $ choco install gsudo
    
  2. Run pls:
    $ pls C:\tools\gsudo\
    
  3. See error.
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\Scripts\pls.exe\__main__.py", line 7, in <module>
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\pls\main.py", line 162, in main
        main_unit(node, show_header)
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\pls\main.py", line 143, in main_unit
        printer.print(show_header)
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\pls\output\printers.py", line 32, in print
        self.print_output()
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\pls\output\table_printer.py", line 139, in print_output
        self.console.print(self.table)
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\console.py", line 1694, in print
        extend(render(renderable, render_options))
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\console.py", line 1326, in render
        for render_output in iter_render:
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\table.py", line 484, in __rich_console__
        widths = self._calculate_column_widths(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\table.py", line 525, in _calculate_column_widths
        width_ranges = [
                       ^
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\table.py", line 526, in <listcomp>
        self._measure_column(console, options, column) for column in columns
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\table.py", line 729, in _measure_column
        _min, _max = get_render_width(console, options, cell.renderable)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\measure.py", line 109, in get
        get_console_width(console, options)
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\padding.py", line 132, in __rich_measure__
        measure_min, measure_max = Measurement.get(console, options, self.renderable)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\measure.py", line 99, in get
        renderable = console.render_str(
                     ^^^^^^^^^^^^^^^^^^^
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\console.py", line 1424, in render_str
        rich_text = render_markup(
                    ^^^^^^^^^^^^^^
      File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\markup.py", line 168, in render
        raise MarkupError(
    rich.errors.MarkupError: closing tag '[/]' at position 61 has nothing to close
    

Expectation

I expect to see a formatted list of the directory...

  Permissions   Size   Modified at                Name
d rwx rwx rwx   -      2023-05-04 07:51:49       Current/
d rwx rwx rwx   -      2023-05-04 07:51:56       v2.0.9/

Environment

  • Device: Virtual Machine
  • OS: Windows Server 2022 Standard
  • OS Version: 21H2, build 20348.1607
  • Python Version: 3.11.3
  • pls Version. 5.4.0
  • gsudo Version: 2.0.9

Additional context

I installed pls using this command: pip install --upgrade --user pls.
This is what my directory looks like using ls:

$ ls

    Directory: C:\tools\gsudo

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
l----            5/4/2023  6:44 AM                Current -> C:\tools\gsudo\v2.0.9\
d----            5/4/2023  6:44 AM                v2.0.9

Support for alternative user-level config file location

Problem

Many command line tools have user-level configs in the home directory, but offer ways to de-clutter that directory by setting custom environmental variables. pls could support this idea fairly simply (I think?).

Description

pls could read an environmental variable called PLS_USER_CONFIG_DIR (or something like that) when constructing the conf_paths list in config/files.py.

There is already at least one environmental variable used by pls, so I don't think it would be too odd to support another one.

Implementation

I admit, I'm not too familiar with the architecture of pls, but a quick look through config/files.py and globals/state.py makes me think implementing this wouldn't be too difficult.

Adding a function get_user_conf() before get_home_conf() in find_configs() could work. Something along the lines of:

def get_user_conf():
    user_conf_dir = os.getenv("PLS_USER_CONFIG_DIR")

    if user_conf_dir is None:
        return None

    test_path = user_conf_dir.joinpath(conf_name)
    return test_path if _is_valid(test_path) else None

This could be inserted into find_configs():

def find_configs():
...
    if ancestor_confs := get_ancestor_confs(curr_dir):
        conf_paths.extend(ancestor_confs)
    if user_conf := get_user_conf():
        conf_paths.append(user_conf)
    if (home_conf := get_home_conf()) and home_conf not in conf_paths:
        conf_paths.append(home_conf)
...
  • πŸ™‹ I would be interested in implementing this feature.

Icons not showing

Description

Heard about this tool on the Python Bytes podcast. Thanks for building and sharing it, it looks super cool!

Reading the docs, it seems like icons are supposed to work out-of-the-box, but I instead just get blank spaces before the file names. The emojis work, but are not as pretty 😞

Reproduction

pipx install pls

Screenshots

image

Environment

  • OS: Ubuntu 20.04.4 LTS running in Docker for Windows, with an X11 server to render the GUI applications.
  • Version: 1.13.1
  • Other info: Using the Starship prompt, which require a Nerd Fonts to be installed manually.

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

Exception on Windows PowerShell7

I don't know if it has compatibility with pwsh (PowerShell 7.2.1), but it would be nice.

❯ pls
Traceback (most recent call last):
  File "C:\Users\fernando\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\fernando\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\fernando\AppData\Roaming\Python\Python310\Scripts\pls.exe\__main__.py", line 7, in <module>
  File "C:\Users\fernando\AppData\Roaming\Python\Python310\site-packages\pls\main.py", line 16, in main
    nodes = read_input()
  File "C:\Users\fernando\AppData\Roaming\Python\Python310\site-packages\pls\fs\list.py", line 82, in read_input
    all_nodes.sort(key=sort_key, reverse=args.sort == SortOrder.DESC)
  File "C:\Users\fernando\AppData\Roaming\Python\Python310\site-packages\pls\fs\list.py", line 31, in sort_key
    prefix = "0" if node.node_type == NodeType.DIR else "1"
  File "C:\Users\fernando\AppData\Local\Programs\Python\Python310\lib\functools.py", line 981, in __get__
    val = self.func(instance)
  File "C:\Users\fernando\AppData\Roaming\Python\Python310\site-packages\pls\models\node.py", line 82, in node_type
    node_type = get_node_type(self.path)
  File "C:\Users\fernando\AppData\Roaming\Python\Python310\site-packages\pls\fs\stats.py", line 130, in get_node_type
    raise ExecException("Could not determine type of the node.")
pls.exceptions.ExecException: Could not determine type of the node.

Folder icons render as ? symbols.

Description

All the folders have ? icon (attached screenshot) , is this the default icon? Am I missing something?

Reproduction

  1. pip install pls
  2. type in pls
  3. See the icons.

Expectation

Folders should have a icon based on name (for common folders) or have just a folder icon, but seeing question mark.

Screenshots

image

Environment

  • Device: Macbook Pro m1
  • OS: MacOs Monterey (12.5)
  • Version: 5.3.0

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

Allow for the use of icons from files

Problem

I couldn't find a nerd font icon for excel spreadsheets (.xlsx or .xls), but I found a nice icon I would have liked to use here.

Description

My understanding is that this would require 2 things to be implemented:

  1. a pls_assets folder to contain the icon images in either png or svg format
  2. a way to point to the icon image in the .pls.yml configuration file

I don't know if this is feasible, but it would be great!

Alternatives

I couldn't find an alternative way to solve the above problem.

Implementation

  • πŸ™‹ I would be interested in implementing this feature.

1.6.0. Crashes with broken symlink

Steam uses a broken symlink in the home folder for backwards compatibility:

.steampath -> /home/username/.steam/sdk32/steam

pls crashes while trying to read this

multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/usr/lib/python3.10/site-packages/pls/fs/list.py", line 43, in parse_nodes
    return Node(node_name, path=node_path)
  File "/usr/lib/python3.10/site-packages/pls/models/node.py", line 26, in __init__
    self.stat = path.stat()
  File "/usr/lib/python3.10/pathlib.py", line 1095, in stat
    return self._accessor.stat(self, follow_symlinks=follow_symlinks)
FileNotFoundError: [Errno 2] No such file or directory: '/home/username/.steampath'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/pls", line 33, in <module>
    sys.exit(load_entry_point('pls==1.6.0', 'console_scripts', 'pls')())
  File "/usr/lib/python3.10/site-packages/pls/main.py", line 16, in main
    nodes = read_input()
  File "/usr/lib/python3.10/site-packages/pls/fs/list.py", line 55, in read_input
    comp_nodes = pool.map(parse_nodes, all_nodes)
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 364, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 771, in get
    raise self._value
FileNotFoundError: [Errno 2] No such file or directory: '/home/username/.steampath'

Need to change the Nerd Font icons that starts with the `nf-mdi` prefix

Description

20230511_031230

The code points have been updated as the material icons are in version 3.0. Because of this, icons such as nf-mdi-git, which are currently used as default, are not displayed normally. All default nf-mdi-* icons should be replaced.

Reproduction

echo "\ufc1d \uf5e1 \uf7a1 \uf7e8 \uf81f \ufc0c \ufcb5 \uf668 \ufb67 \ufa66 \ufd42"

Screenshots

20230511_035538

Environment

  • Device: macOS
  • OS: Ventura 13.3.1 (a)
  • Font: JetBrainsMonoNL NF Regular
  • Version: Latest

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

Traceback errors when used in empty directory.

Description

When running pls in an empty directory there is traceback debug information given. This seems like a crash in the application. I would be expecting to see no output.

Reproduction

  1. Create an empty directory mkdir /tmp/empty
  2. Change into directory cd /tmp/empty
  3. List contents of empty directory pls

Expectation

I would expect to see no print results.

Screenshots

Screenshot from 2022-04-26 22-07-59

Environment

  • Device: laptop
  • OS: Fedora 36
  • Browser:
  • Version: 4.0.2
  • Other info:

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

Crashes on OS X Catalina with "KeyError: getgrgid(): gid not found: <number>"

Description

When I run pls, it crashes every time with the error listed in the issue title.

Reproduction

  1. brew install pipx
  2. pipx install pls
  3. pls --help
  4. See error.

Expectation

I expected it to work correctly.

Screenshots

Traceback (most recent call last):
  File "/Users/ybxh061/.local/bin/pls", line 5, in <module>
    from pls.main import main
  File "/Users/ybxh061/.local/pipx/venvs/pls/lib/python3.10/site-packages/pls/main.py", line 2, in <module>
    from pls import globals
  File "/Users/ybxh061/.local/pipx/venvs/pls/lib/python3.10/site-packages/pls/globals.py", line 124, in <module>
    state.parse_args([])  # parse a blank list of arguments as the default
  File "/Users/ybxh061/.local/pipx/venvs/pls/lib/python3.10/site-packages/pls/globals.py", line 64, in parse_args
    self.setup()
  File "/Users/ybxh061/.local/pipx/venvs/pls/lib/python3.10/site-packages/pls/globals.py", line 73, in setup
    getattr(self, f"setup_{setup_fn}")()
  File "/Users/ybxh061/.local/pipx/venvs/pls/lib/python3.10/site-packages/pls/globals.py", line 112, in setup_user_groups
    self.groups.add(getgrgid(gid).gr_name)
KeyError: 'getgrgid(): gid not found: <NUMBER>'

Environment

  • Device: Macbook Pro
  • OS: 10.15.7 (Catalina)
  • Browser: Chrome
  • Version: 1.14.0
  • Other info: iTerm2 terminal

Additional context

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

Add a tree view

Problem

One of the most requested features lacking in pls but present in its main competition, exa is a tree view.

Description

A tree view is very useful to see the contents of a directory, and it's subdirectories, and their subdirectories and so on in a single view.

exa has this feature, accessible with the --tree flag but pls does not. Adding it would close the gap, making pls's features a superset of exa.

Additional context

  • The feature must be compatible with the details view.
  • It must override and disable collapse mode.

Coloring of date fields inconsistent

Description

When using pls in table ode, any fields containg a date are highlighted somewhat strange. The color of the year and seconds are not the same as the other components.

Reproduction

  1. pls -a -d ctime
  2. See error.

Expectation

The whole date field has the same color.

Screenshots

pls_date

Environment

  • Device: cloud ecs
  • OS: arch linux
  • Shell: zsh

Additional context

I suspect rich for the output formatting lapse. But I can't reproduce this with rich:

import rich
rich.print("2022-03-01 10:00:00") 

gives me the date and the time in one color for the time and date respectively.
Maybe add markup=False on the ourput for date colums?

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

Please support Windows

Problem

The new rust version of pls does not support Windows.

Description

I love pls! The old python version of pls supported Windows (mostly) and is my default ls program. However, the new rust version does not. It is also really useful for those of us who use both Windows and Linux (WSL) to have the same ls tool on both platforms. Please consider supporting Windows with the new rust implementation. Thank you!

Git file with space raise exception

Description

File in git repo with space, shlex.split() make a longer list than accepted by PLS.

Reproduction

Create the file

mkdir test
cd test
git init
touch "file.txt badly formatted with more word than the 3 accepted by the code"

Just run pls and it raise ExecException: Could not parse Git status code.

The status can be wrong if components == 3

Expectation

Do not raise exception, perhaps log warning. And have a better split.

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

Fix broken CI workflow

Problem

Debug and fix CI, which keeps failing in the repo. This might need an update to Poetry and some dependencies.

Exception throw when listing non readable files

Description

Exception is throw when trying to list directories that the user has not access to view.

Reproduction

Create the temporary files

mkdir /tmp/test
touch /tmp/test/test

sudo chown -R root:root /tmp/test
sudo chmod -R 400 /tmp/test

Checkout from ls

ls /tmp/test

ls: cannot open directory '/tmp/test': Permission denied`

When trying the same with pls an exception is throw.

pls /tmp/test

Traceback (most recent call last):
  File "/home/boomatang/.local/bin/pls", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/boomatang/.local/pipx/venvs/pls/lib64/python3.11/site-packages/pls/main.py", line 160, in main
    node_specific_init(node, cli_prefs)
  File "/home/boomatang/.local/pipx/venvs/pls/lib64/python3.11/site-packages/pls/main.py", line 64, in node_specific_init
    state.state.setup_git(node)
  File "/home/boomatang/.local/pipx/venvs/pls/lib64/python3.11/site-packages/pls/globals/state.py", line 120, in setup_git
    self.git_root = get_git_root(directory)
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/boomatang/.local/pipx/venvs/pls/lib64/python3.11/site-packages/pls/fs/git.py", line 73, in get_git_root
    proc = exec_git(
           ^^^^^^^^^
  File "/home/boomatang/.local/pipx/venvs/pls/lib64/python3.11/site-packages/pls/fs/git.py", line 52, in exec_git
    proc = subprocess.run(
           ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib64/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: PosixPath('/tmp/test')

Expectation

Would have expected a better error message.

Screenshots

Environment

  • Device:
  • OS: Fedora 38
  • Browser:
  • Version: 5.4.0
  • Other info:

Additional context

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

unix `ctime` is "change time" not "creation time"

Description

In documentation as well as output, when pls refers to ctime, it characterizes that time as the file's creation time. This is a common misconception. On most unix and unix-like operating systems, ctime is The inode's "change time." In fact I believe there is no POSIX standard to track file creation time (sometimes called birthtime).

Some filesystems (e.g., APFS & HFS+ on macOS) do report file creation time, where as others (e.g., ext4 on Linux) do not.

How does that differ from mtime you may ask. mtime (as well as ctime) is updated when the contents of the inode are changed. If only the file's metadata (e.g., ownership, permissions, etc.) are changed, then only the inode's ctime will be updated.

Reproduction

  1. create a file: e.g., ls -l > listing.txt
  2. stat it
  3. pls -d ctime -d mtime -d atime the file & see the respective times match
  4. chmod +x the file
  5. stat and pls the file as before
  6. see that only ctime has been updated, which is clearly not the file's creation time

Expectation

In documentation as well as output ctime should be referred to as "change time" or simply ctime

Screenshots

Environment

maOS:

ProductName:	macOS
ProductVersion:	12.3.1
BuildVersion:	21E258

Ubuntu:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"

Additional context

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

Collect solo files into a single, separate output group

Description

Solo files should be collected into a single table/grid when listing. If separated into their own groups, they waste a lot of space.

$ pls /bin/ls /usr/bin/sqlite3 /Users/dhruvkb/Developer/personal/mega/pls -g=true
Screenshot 2023-08-28 at 6 21 35 AM

Expectations

Here's how ls and exa both handle the same input arguments.

Screenshot 2023-08-28 at 6 22 09 AM

The individual files are collected and displayed as one grid, and the directory appears in its own grid with a heading.

Workarounds

In certain specific cases, such as when listing files in the same directory, name-filters can be used to emulate the expected behaviour.

Screenshot 2023-08-28 at 6 28 52 AM

Additional information

This issue was raised in discussion #81.

Support generic folder/directory color and icon changes

Problem

Forgive me for opening another issue so quickly! This is an excellent application, and I've been enjoying using it. I can't seem to find documentation about how to change the default directory icon or color.

I have tried an extension node with an empty string, and a pattern node which looks for \ or / at the end of the name. Neither have worked, and without any examples in the documentation, I'm assuming this idea is not supported at the moment.

Description

It would be very nice to be able to specify directories either by pattern or extension, or some other mechanism within .pls.yml. This would allow the user to change the default directory color or icon.

Alternatives

What I am trying to do is match the color output of pls to the color output of ls, which uses the LS_COLORS environmental variable. pls could make the default output colors use this variable, but it is not always set for users. On macOS, it is only used if the users use the GNU-based ls, for example. I think a simpler solution would be to make it easier to change directory colors, and allow the user to input any other extensions or patterns they want. That part is already very simple thanks to the excellent config!

Additional context

My apologies if this is already supported! I looked long and hard through the documentation but failed to find the solution to this.

Implementation

  • πŸ™‹ I would be interested in implementing this feature.

Make upgrade nag configurable

Problem

Currently when a new version of pls comes out, it seems that every time the user uses the tool it appends to the output that there is an upgrade. It seems like it might even make an HTTP request every time? I would suggest that this feature should at least be toggleable at the config level and documented. I would go further and argue that this should probably be avoided altogether or defaulted to off.

Description

This can be problematic if you're using it for scripts and can be quite annoying to the user, especially if they install through their package manager and just have to wait for the update to become available. It also seems inappropriate that a relatively low level command would insist so heavily in upgrades or make an HTTP call on every use.

KeyError: 'getpwuid(): uid not found' if userid does not exist on system

Description

On my system I have a number of folders that are owned by a user that does not exist on the system (502 in this case, this is ls -Fla output):

drwxr-xr-x  18 adamparkin  staff       576 20 Mar  2021 site2/
drwxr-xr-x  19 adamparkin  staff       608 27 Apr  2021 skeleton/
drwxr-xr-x   6 502         staff       192  7 Dec  2014 slack-cli/
drwxr-xr-x   6 502         staff       192 14 Feb  2016 slackcmd/

Can see that two of those directories are owned by me (adamparkin) and two by a non-existent user (502). When I run pls -d in this directory it crashes with:

 Ξ» pls -d
Traceback (most recent call last):
  File "/Users/adamparkin/.local/bin/pls", line 8, in <module>
    sys.exit(main())
  File "/Users/adamparkin/.local/pipx/venvs/pls/lib/python3.9/site-packages/pls/main.py", line 34, in main
    write_output(node_list)
  File "/Users/adamparkin/.local/pipx/venvs/pls/lib/python3.9/site-packages/pls/output/table.py", line 114, in write_output
    tabulate_node(table, node)
  File "/Users/adamparkin/.local/pipx/venvs/pls/lib/python3.9/site-packages/pls/output/table.py", line 91, in tabulate_node
    data = node.table_row
  File "/opt/homebrew/Cellar/[email protected]/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/functools.py", line 969, in __get__
    val = self.func(instance)
  File "/Users/adamparkin/.local/pipx/venvs/pls/lib/python3.9/site-packages/pls/models/node.py", line 185, in table_row
    cells.update(self.stat_cells)
  File "/opt/homebrew/Cellar/[email protected]/3.9.2_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/functools.py", line 969, in __get__
    val = self.func(instance)
  File "/Users/adamparkin/.local/pipx/venvs/pls/lib/python3.9/site-packages/pls/models/mixins/stat.py", line 63, in stat_cells
    cells[column] = function(self.stat, *func_args)
  File "/Users/adamparkin/.local/pipx/venvs/pls/lib/python3.9/site-packages/pls/fs/stats.py", line 86, in get_formatted_user
    pw_name = getpwuid(stat.st_uid).pw_name
KeyError: 'getpwuid(): uid not found: 502'

Reproduction

See description

Expectation

It not to throw an exception and produce the same output as ls

Screenshots

N/A

Environment

  • Device: Macbook Air (M1)
  • OS: Big Sur 11.6.4
  • Browser: Not applicable?
  • Version: Not applicable?
  • Other info:

Additional context

These folders with the missing user got created by copying directories from a backup from another old Macbook to this machine.

Resolution

  • πŸ™‹ I would be interested in resolving this bug.

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.