167 Commits
Author SHA1 Message Date
d37a763a6a Escape calls for sed and awk in case someone aliased them (#264)
Co-authored-by: Jonathan Dahan <hi@jonathan.is>
Co-authored-by: rupa <rupa@lrrr.us>
2023-12-09 17:41:33 -05:00
rupa 703bb54e63 avoid issues when date has been aliased
Closes #323
2023-12-09 17:38:07 -05:00
rupa 6ba07224f7 avoid issues when env has been aliased
Closes #325
2023-12-09 17:35:12 -05:00
Queensferry b82ac78a2d Skip excluding when $_Z_EXCLUDE_DIRS is empty (#302) 2021-05-31 13:23:39 -04:00
Eric Nielsen 574f64b84e Also don't match the root directory (#216)
besides the `$HOME` directory.

A `z /` call will cd to the root directory anyway, because of how the
code handles completion:

    # if we hit enter on a completion just go there
    case "$last" in
        # completions will always start with /
        /*) [ -z "$list" -a -d "$last" ] && builtin cd "$last" && return;;
    esac
2021-05-26 13:59:50 -04:00
Robert Liebowitz 61b5c5be69 Fix no such file or directory error (#256) 2021-05-26 13:58:27 -04:00
chewblacka 77622bbc25 Update z.sh (#293)
Double-quote in wrong position meant that Excluding directories feature didn't work.
2021-05-26 13:57:42 -04:00
Rubén Durán Balda 125f4dc47e Fix -r and -t options with common dirs (fixes #235) (#249) 2020-09-29 10:36:00 -04:00
Rubén Durán Balda 9f76454b32 Add -x and -h options to the script header doc (#272) 2020-05-18 16:18:43 -04:00
Marc Cornellà bbec3cb6af Fix zsh stalled $RANDOM variable (#247)
This change references `$RANDOM` outside the subshell to refresh it for the
next subshell invocation. Otherwise, subsequent runs of the function get the
same value and, if run simultaneously, they may clobber each others' temp .z
files.

This is due to how zsh distributes RANDOM values when running inside a
subshell: 

  subshells that reference RANDOM will result in identical pseudo-random
  values unless the value of RANDOM is referenced or seeded in the parent
  shell in between subshell invocations

See: http://zsh.sourceforge.net/Doc/Release/Parameters.html#index-RANDOM
2020-04-03 01:56:04 -04:00
silenc3r 6586b61384 Avoid race condition when listing matches (#238) 2020-03-06 01:04:58 -05:00
rupa 9723bc0669 welp 2020-03-06 01:01:19 -05:00
rupa 80d82084d9 better exit codes fwiw
afaict all three of these exit lines are required 🤷
2020-03-06 00:45:45 -05:00
Eric Nielsen 379a72dc5d Return zero when listing with -l (#212)
Current logic returns a non-zero code, because `"$cd"` is empty when
using `-l`.
2020-03-05 23:54:22 -05:00
rupa f1f113d9ba avoid sort -g
scale the score so we can work with ints
2020-02-15 16:56:40 -05:00
rupa 4f08e7febb continuous frecency
a curve that seems to fit original behavior pretty closely.

h/t @dcervenkov
2019-10-24 01:49:52 -04:00
rupa dcd5541e7d Allow changing the max score for aging
user can set _Z_MAX_SCORE (probably not the greatest name). Closes #231
2019-10-24 01:32:02 -04:00
GHPS e77e938493 Corrected sort order in tab completion (#270)
The tab completion for z lists hits in wrong order, not by rank. Switching from "-n" to "-g" for sort (i.e. general numeric) is required for the float rank value.
2019-09-12 19:28:03 -04:00
rupa 9d5a3fe040 declare some local vars unconditionally
So they don't pick up if e.g. tmux defines $echo
2018-08-10 12:14:43 -04:00
daninthewoods ad437e8860 Support for group names containing spaces (#245)
When Active Directory is used for Mac authentication then the group name could be "MyCompany\Domain Users".  This causes an error in z during the chown such as "chown: MyCompany\Domain: illegal group name"
2018-08-02 11:58:49 -04:00
Rubén Durán Balda fdf133e9fe Fix -e option (fixes #239) (#242) 2018-06-09 18:32:18 -04:00
rupa ea5ec78343 pipe calls to _z_dirs, and a litle simplification
h/t @ericbn. Closes #217 and #196 maybe
2018-01-23 10:17:47 -05:00
rupa 2ebe419ae1 whitespace cleanup 2017-12-18 16:52:15 -05:00
Eric Nielsen fed3b7a122 Use index(s, t) instead of regular expression (#214)
for checking the common root. It is a simpler implementation.

I see a similar logic, still using `~!` comparison exists since initial
commit (9b240f3):

        } else for( i in a ) if( shortest !~ a[i] ) x = 1

Rename parameters in `output` function to avoid using multiple names for
the same domains. Use the same names as in other functions.
2017-12-18 16:50:32 -05:00
rupa 0a47c9ceca dereference symlinked datafile
Closes #163
2017-07-26 19:27:33 -04:00
rupa 3eb64444d7 typo 2017-06-18 19:49:00 -04:00
rupa 1379584090 whitespace 2017-06-18 19:43:40 -04:00
rupa 7b2e8d8a50 License clarification 2017-06-18 19:42:18 -04:00
rupa 1a361f6dc1 Async PROMPT_COMMAND for zsh
h/t @balta2ar
2016-09-30 09:58:23 -04:00
rupa 4a8b741d19 Async PROMPT_COMMAND
Speed up prompt by updating in the background. Might lead to more
~/.z.XXXX litter and less accurate counts - let's see.
2016-09-30 09:58:23 -04:00
rupa 78f0d97d3d silence error from zsh when datafile is created 2016-07-21 13:10:24 -04:00
rupa 335717ef08 fix -e without breaking zsh 2016-07-21 13:09:14 -04:00
rupa 62e9cdc11d fix zsh builtin complaints
remove a uselessly clever variable substitution
2016-07-20 21:38:22 -04:00
rupa 91cbf1a326 Use builtin cd in case you've messed with it. 2016-07-20 19:57:46 -04:00
Paul Phillips 3143b28dd9 Check intended exit code. Fixes #177. (#178)
* Check intended exit code. Fixes #177.

Use PIPESTATUS rather than $? to check last program in a pipeline.

* Avoid PIPESTATUS/pipestatus entirely.

Use process substitution to obtain input and sidestep the
question of where the exit code is.
2016-04-23 15:08:38 -04:00
rupa cd9f1e2d96 streamline implementation of -e flag 2016-01-25 20:02:17 -05:00
rupa d0cf5282df add -e flag to echo best match only (no cd)
-l lists and does not cd, but has enough extra stuff going on to make
it a bit of a pain if you want to parse out just the best match for
your own nefarious purposes - therefore this.
h/t @synthetiv. Closes #161
2016-01-25 19:43:16 -05:00
rupa 5dc2a863cc Merge branch 'master' of github.com:rupa/z 2015-09-13 16:38:00 -04:00
rupa e12eefeeb2 use type in shell checks
shouldn't change behavior, and should be faster on load.
2015-09-13 16:35:17 -04:00
Kylie McClain eda8015880 fix special char escaping so mawk likes it 2015-04-13 20:42:43 -04:00
Tom Hoover 054cf43fbe commit c507bdd broke zsh -- this fixes it 2015-02-16 21:26:24 -06:00
rupa 588fbb917b Merge pull request #130 from notwa/quiet_shift
Prevent extraneous shifting
2015-02-14 13:42:56 -05:00
rupa c507bdd707 also ignore subdirs of _Z_EXCLUDE_DIRS 2015-02-14 13:24:04 -05:00
rupa b620b0a8af Age a bit slower. 2014-08-31 13:24:36 -04:00
rupa f0a71cae87 remove tab literal 2014-08-31 13:06:38 -04:00
rupa a830cc1cd4 Merge branch 'master' into ordered_args 2014-08-07 11:16:12 -04:00
Dan Bolsun 79aa545cd7 Allow usage of z while in 'sudo -s' mode 2014-07-02 11:02:46 +03:00
rupa 4fab37850e Merge branch 'master' into ordered_args 2014-06-27 12:44:58 -04:00
rupa 56027bfa61 suppress error from tab completion when datafile not exists
h/t @juanpabloaj. Closes #136
2014-06-27 12:42:47 -04:00
rupa 0f559cd60a Merge branch 'master' into ordered_args 2014-05-28 11:12:49 -04:00