Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Search directory] Append / instead of prepending ./ for quick cd #185

Merged
merged 7 commits into from
Jul 17, 2021

Conversation

PatrickF1
Copy link
Owner

@PatrickF1 PatrickF1 commented Jul 4, 2021

I decided appending / is a better, cleaner solution for quick cd than appending ./

  • since prepending ./ is causing issues when the path starts with . or /, why not just append /? fd never appends / to its output so this is safe to do (see Display directories with trailing slashes sharkdp/fd#436)
  • of course, we can't just append / to everything; we need to test if the path is actually a directory, but since we only do this when there's one path selected, it's not performance hindering
  • a / at the end of only directories is cleaner, more natural, and has a more comprehensible than prepending ./ to anything even when it's not needed
  • the code and documentation become much more straightforward
  • this will remove support for executables, which cuts back on product debt
  • fixes Auto prepend ./ for quick directory change doesn't work if directory starts with . #171 (is compatible with hidden directories)

This is about the same as the PR that started this all (#72) except we're using a trailing / instead.

Do note that symlink behavior changes if the directory has a trailing / (#185 (comment)).

@kidonng
Copy link
Contributor

kidonng commented Jul 4, 2021

Also read the original PR for why I changed my mind to prepend ./ instead of appending /.

More examples of appending / changing other program's behavior (seems to only affect symlinks though):

~                                                                                                             
❯ command ls -l .nix-profile
lrwxr-xr-x  1 kid  staff  42 Jun 15 17:39 .nix-profile -> /nix/var/nix/profiles/per-user/kid/profile

~                                                                                                             
❯ command ls -l .nix-profile/
lrwxr-xr-x  1 kid  staff  16 Jul  4 14:04 .nix-profile/ -> profile-116-link

~                                                                                                             
❯ exa -l .nix-profile
dr-xr-xr-x  - kid  1 Jan  1970 bin
dr-xr-xr-x  - kid  1 Jan  1970 etc
lrwxr-xr-x 69 kid  1 Jan  1970 include -> /nix/store/kc4y8h2zf62adzyf9jsbpsfzlq4cpvyb-home-manager-path/include
dr-xr-xr-x  - kid  1 Jan  1970 lib
dr-xr-xr-x  - kid  1 Jan  1970 libexec
lrwxr-xr-x 62 kid  1 Jan  1970 Library -> /nix/store/mingfa89931g313929ixmr7wzcxjkyi3-nix-2.3.12/Library
lrwxr-xr-x 66 kid  1 Jan  1970 sbin -> /nix/store/kc4y8h2zf62adzyf9jsbpsfzlq4cpvyb-home-manager-path/sbin
dr-xr-xr-x  - kid  1 Jan  1970 share
lrwxr-xr-x 60 kid  1 Jan  1970 manifest.nix -> /nix/store/4iydni7d2f0dq9by6g1m9dz7xb34xdsr-env-manifest.nix

~                                                                                                             
❯ exa -l .nix-profile/
lrwxr-xr-x 16 kid  4 Jul 14:04 .nix-profile -> profile-116-link

~                                                                                                             
❯ command stat .nix-profile
16777220 12884994046 lrwxr-xr-x 1 kid staff 0 42 "Jun 15 17:39:05 2021" "Jun 15 17:39:05 2021" "Jun 15 17:39:05 2021" "Jun 15 17:39:05 2021" 4096 0 0 .nix-profile

~                                                                                                             
❯ command stat .nix-profile/
16777226 2189825 lrwxr-xr-x 1 kid staff 0 16 "Jul  4 14:04:01 2021" "Jul  4 14:04:01 2021" "Jul  4 14:04:01 2021" "Jul  4 14:04:01 2021" 4096 0 0 .nix-profile/

@PatrickF1
Copy link
Owner Author

Also read the original PR for why I changed my mind to prepend ./ instead of appending /.

Thanks. I replied in #171. Let's keep the discussion there.

@PatrickF1 PatrickF1 merged commit 1fca707 into main Jul 17, 2021
@PatrickF1 PatrickF1 deleted the append-slash-instead branch July 17, 2021 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto prepend ./ for quick directory change doesn't work if directory starts with .
2 participants