jethrokuan / z

Pure-fish z directory jumping
MIT License
1.26k stars 44 forks source link

Freezes on MacOS? #81

Closed geoffreywiseman closed 3 years ago

geoffreywiseman commented 4 years ago

Seeing some weird slowdowns on macOS that seem to come down to this z integration.

I'm in macOS, changing into a directory where I've just downloaded an exorcism exercise in Rust, and cd is freezing in a weird way, so I check my process list and see: awk -v path /Users/geoffrey/work/learning/exercism/rust/reverse-string -v now 1575526304 -F

I was suspicious that it was z since I'd only installed the fish z-equiv recently, and cd integration is important to z, but it didn't take long to find that this line is from z.

If I paste that line myself, I get: awk -v path /Users/geoffrey/work/learning/exercism/rust/reverse-string -v now 1575526304 -F awk: invalid -v option

krobelus commented 4 years ago

try executing the command below, it is essentially what z is doing to update the $Z_DATA when changing directories; check if it shows any error. Also check the contents of your $Z_DATA file, it should have lines like this: /some/path|1|1575534980 (path, ranking, last used)

command awk -v path=$PWD -v now=(date +%s) -F "|" '
      BEGIN {
          rank[path] = 1
          time[path] = now
      }
      $2 >= 1 {
          if( $1 == path ) {
              rank[$1] = $2 + 1
              time[$1] = now
          }
          else {
              rank[$1] = $2
              time[$1] = $3
          }
          count += $2
      }
      END {
          if( count > 1000 ) {
              for( i in rank ) print i "|" 0.9*rank[i] "|" time[i] # aging
          }
          else for( i in rank ) print i "|" rank[i] "|" time[i]
      }
    ' $Z_DATA
geoffreywiseman commented 4 years ago

TBH, I uninstalled, because I was having a hard time changing directories and I didn't know the quickiest way to disable a fisher plugin. I'll reinstall, and if it recurs, I'll let you know.

jorgebucaran commented 3 years ago

@krobelus Think we can close here? 👍

krobelus commented 3 years ago

Yeah, we can reopen if it ever happens again.

Recent fish allows to set fish_trace 1, to log commands which may be helpful to find out where a freeze occurs.

If I paste that line myself, I get: awk -v path /Users/geoffrey/work/learning/exercism/rust/reverse-string -v now 1575526304 -F awk: invalid -v option

The ps output doesn't add quoting to special shell characters, so copying commands sometimes goes wrong. For example the -F "|" option shows up as -F |. When executing that in the shell, the | is interpreted as pipe.

No idea where the missing = went, it's supposed to be -v path=/Users/....