├── .github └── workflows │ └── ci.yml ├── .gitignore ├── LICENSE ├── README.md ├── THANKS.md ├── conf.d └── z.fish ├── functions ├── __z.fish ├── __z_add.fish ├── __z_clean.fish └── __z_complete.fish ├── man └── man1 │ ├── z.1 │ └── z.md └── test └── z.fish /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v2 11 | - name: Install Fish 12 | run: | 13 | sudo apt-add-repository -yn ppa:fish-shell/release-3 14 | sudo apt-get update 15 | sudo apt-get install -y fish 16 | 17 | - name: Install Fisher & Fishtape 18 | run: curl -sL git.io/fisher | source && fisher install jorgebucaran/{fisher,fishtape} 19 | shell: fish {0} 20 | 21 | - name: Run Tests 22 | run: | 23 | $GITHUB_WORKSPACE/ && fisher install . 24 | fishtape test/*.fish 25 | shell: fish {0} 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /README.html 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (C) 2016 Jethro Kuan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/jethrokuan/z.svg?branch=master)](https://travis-ci.org/jethrokuan/z) 2 | 3 | # Z 4 | 5 | **z** is a port of [z](https://github.com/rupa/z) for the [fish shell](https://fishshell.com). 6 | 7 | **z** tracks the directories you visit. With a combination of frequency and recency, it enables you to jump to the directory in mind. 8 | 9 | A _pure-fish_ port means **z** is _fast_ and _fish-friendly_, with tab-completions and lazy-loading. Top that off with great customizability and a small amount of added functionality. 10 | 11 | Originally written by [@jethrokuan](https://github.com/jethrokuan/), co-maintained with [@krobelus](https://github.com/krobelus). 12 | 13 | ## Installation 14 | 15 | Install with [Fisher](https://github.com/jorgebucaran/fisher): 16 | 17 | ```console 18 | fisher install jethrokuan/z 19 | ``` 20 | 21 | For fish <`2.7.0` users you can install from our legacy branch: 22 | 23 | ``` 24 | fisher install z@pre27 25 | ``` 26 | 27 | ## Usage 28 | 29 | See [man/man1/z.md](https://github.com/jethrokuan/z/blob/master/man/man1/z.md) for details. 30 | 31 | ## License 32 | 33 | Z is MIT licensed. See the [LICENSE](LICENSE) for details. 34 | -------------------------------------------------------------------------------- /THANKS.md: -------------------------------------------------------------------------------- 1 | # Thank You 2 | The following individuals have contributed to `z` :heart: 3 | 4 | * [James Campos](https://github.com/aeosynth) 5 | * [Jethro Kuan](https://github.com/jethrokuan) 6 | * [Jorge Bucaran](https://github.com/bucaran) 7 | * [rupa](https://github.com/rupa) for the original code 8 | * [sjl](https://github.com/sjl) for the original fish port 9 | -------------------------------------------------------------------------------- /conf.d/z.fish: -------------------------------------------------------------------------------- 1 | if test -z "$Z_DATA" 2 | if test -z "$XDG_DATA_HOME" 3 | set -U Z_DATA_DIR "$HOME/.local/share/z" 4 | else 5 | set -U Z_DATA_DIR "$XDG_DATA_HOME/z" 6 | end 7 | set -U Z_DATA "$Z_DATA_DIR/data" 8 | end 9 | 10 | if test ! -e "$Z_DATA" 11 | if test ! -e "$Z_DATA_DIR" 12 | mkdir -p -m 700 "$Z_DATA_DIR" 13 | end 14 | touch "$Z_DATA" 15 | end 16 | 17 | if test -z "$Z_CMD" 18 | set -U Z_CMD z 19 | end 20 | 21 | set -U ZO_CMD "$Z_CMD"o 22 | 23 | if test ! -z $Z_CMD 24 | function $Z_CMD -d "jump around" 25 | __z $argv 26 | end 27 | end 28 | 29 | if test ! -z $ZO_CMD 30 | function $ZO_CMD -d "open target dir" 31 | __z -d $argv 32 | end 33 | end 34 | 35 | if not set -q Z_EXCLUDE 36 | set -U Z_EXCLUDE "^$HOME\$" 37 | else if contains $HOME $Z_EXCLUDE 38 | # Workaround: migrate old default values to a regex (see #90). 39 | set Z_EXCLUDE (string replace -r -- "^$HOME\$" '^'$HOME'$$' $Z_EXCLUDE) 40 | end 41 | 42 | # Setup completions once first 43 | __z_complete 44 | 45 | function __z_on_variable_pwd --on-variable PWD 46 | __z_add 47 | end 48 | 49 | function __z_uninstall --on-event z_uninstall 50 | functions -e __z_on_variable_pwd 51 | functions -e $Z_CMD 52 | functions -e $ZO_CMD 53 | 54 | if test ! -z "$Z_DATA" 55 | printf "To completely erase z's data, remove:\n" >/dev/stderr 56 | printf "%s\n" "$Z_DATA" >/dev/stderr 57 | end 58 | 59 | set -e Z_CMD 60 | set -e ZO_CMD 61 | set -e Z_DATA 62 | set -e Z_EXCLUDE 63 | end 64 | -------------------------------------------------------------------------------- /functions/__z.fish: -------------------------------------------------------------------------------- 1 | function __z -d "Jump to a recent directory." 2 | function __print_help -d "Print z help." 3 | printf "Usage: $Z_CMD [-celrth] string1 string2...\n\n" 4 | printf " -c --clean Removes directories that no longer exist from $Z_DATA\n" 5 | printf " -d --dir Opens matching directory using system file manager.\n" 6 | printf " -e --echo Prints best match, no cd\n" 7 | printf " -l --list List matches and scores, no cd\n" 8 | printf " -p --purge Delete all entries from $Z_DATA\n" 9 | printf " -r --rank Search by rank\n" 10 | printf " -t --recent Search by recency\n" 11 | printf " -x --delete Removes the current directory from $Z_DATA\n" 12 | printf " -h --help Print this help\n\n" 13 | end 14 | function __z_legacy_escape_regex 15 | # taken from escape_string_pcre2 in fish 16 | # used to provide compatibility with fish 2 17 | for c in (string split -- '' $argv) 18 | if contains $c (string split '' '.^$*+()?[{}\\|-]') 19 | printf \\ 20 | end 21 | printf '%s' $c 22 | end 23 | end 24 | 25 | set -l options h/help c/clean e/echo l/list p/purge r/rank t/recent d/directory x/delete 26 | 27 | argparse $options -- $argv 28 | 29 | if set -q _flag_help 30 | __print_help 31 | return 0 32 | else if set -q _flag_clean 33 | __z_clean 34 | printf "%s cleaned!\n" $Z_DATA 35 | return 0 36 | else if set -q _flag_purge 37 | echo >$Z_DATA 38 | printf "%s purged!\n" $Z_DATA 39 | return 0 40 | else if set -q _flag_delete 41 | sed -i -e "\:^$PWD|.*:d" $Z_DATA 42 | return 0 43 | end 44 | 45 | set -l typ 46 | 47 | if set -q _flag_rank 48 | set typ rank 49 | else if set -q _flag_recent 50 | set typ recent 51 | end 52 | 53 | set -l z_script ' 54 | function frecent(rank, time) { 55 | dx = t-time 56 | if( dx < 3600 ) return rank*4 57 | if( dx < 86400 ) return rank*2 58 | if( dx < 604800 ) return rank/2 59 | return rank/4 60 | } 61 | 62 | function output(matches, best_match, common) { 63 | # list or return the desired directory 64 | if( list ) { 65 | cmd = "sort -nr" 66 | for( x in matches ) { 67 | if( matches[x] ) { 68 | printf "%-10s %s\n", matches[x], x | cmd 69 | } 70 | } 71 | } else { 72 | if( common ) best_match = common 73 | print best_match 74 | } 75 | } 76 | 77 | function common(matches) { 78 | # find the common root of a list of matches, if it exists 79 | for( x in matches ) { 80 | if( matches[x] && (!short || length(x) < length(short)) ) { 81 | short = x 82 | } 83 | } 84 | if( short == "/" ) return 85 | for( x in matches ) if( matches[x] && index(x, short) != 1 ) { 86 | return 87 | } 88 | return short 89 | } 90 | 91 | BEGIN { 92 | hi_rank = ihi_rank = -9999999999 93 | } 94 | { 95 | if( typ == "rank" ) { 96 | rank = $2 97 | } else if( typ == "recent" ) { 98 | rank = $3 - t 99 | } else rank = frecent($2, $3) 100 | if( $1 ~ q ) { 101 | matches[$1] = rank 102 | } else if( tolower($1) ~ tolower(q) ) imatches[$1] = rank 103 | if( matches[$1] && matches[$1] > hi_rank ) { 104 | best_match = $1 105 | hi_rank = matches[$1] 106 | } else if( imatches[$1] && imatches[$1] > ihi_rank ) { 107 | ibest_match = $1 108 | ihi_rank = imatches[$1] 109 | } 110 | } 111 | 112 | END { 113 | # prefer case sensitive 114 | if( best_match ) { 115 | output(matches, best_match, common(matches)) 116 | } else if( ibest_match ) { 117 | output(imatches, ibest_match, common(imatches)) 118 | } 119 | } 120 | ' 121 | 122 | set -l qs 123 | for arg in $argv 124 | set -l escaped $arg 125 | if string escape --style=regex '' >/dev/null 2>&1 # use builtin escape if available 126 | set escaped (string escape --style=regex -- $escaped) 127 | else 128 | set escaped (__z_legacy_escape_regex $escaped) 129 | end 130 | # Need to escape twice, see https://www.math.utah.edu/docs/info/gawk_5.html#SEC32 131 | set escaped (string replace --all -- \\ \\\\ $escaped) 132 | set qs $qs $escaped 133 | end 134 | set -l q (string join -- '.*' $qs) 135 | 136 | if set -q _flag_list 137 | # Handle list separately as it can print common path information to stderr 138 | # which cannot be captured from a subcommand. 139 | command awk -v t=(date +%s) -v list="list" -v typ="$typ" -v q="$q" -F "|" $z_script "$Z_DATA" 140 | return 141 | end 142 | 143 | set target (command awk -v t=(date +%s) -v typ="$typ" -v q="$q" -F "|" $z_script "$Z_DATA") 144 | 145 | if test "$status" -gt 0 146 | return 147 | end 148 | 149 | if test -z "$target" 150 | printf "'%s' did not match any results\n" "$argv" 151 | return 1 152 | end 153 | 154 | if set -q _flag_echo 155 | printf "%s\n" "$target" 156 | else if set -q _flag_directory 157 | if test -n "$ZO_METHOD" 158 | type -q "$ZO_METHOD"; and "$ZO_METHOD" "$target"; and return $status 159 | echo "Cannot open with ZO_METHOD set to $ZO_METHOD"; and return 1 160 | else if test "$OS" = Windows_NT 161 | # Be careful, in msys2, explorer always return 1 162 | type -q explorer; and explorer "$target" 163 | return 0 164 | echo "Cannot open file explorer" 165 | return 1 166 | else 167 | type -q xdg-open; and xdg-open "$target"; and return $status 168 | type -q open; and open "$target"; and return $status 169 | echo "Not sure how to open file manager"; and return 1 170 | end 171 | else 172 | pushd "$target" 173 | end 174 | end 175 | -------------------------------------------------------------------------------- /functions/__z_add.fish: -------------------------------------------------------------------------------- 1 | function __z_add -d "Add PATH to .z file" 2 | test -n "$fish_private_mode"; and return 0 3 | 4 | for i in $Z_EXCLUDE 5 | if string match -r $i $PWD >/dev/null 6 | return 0 #Path excluded 7 | end 8 | end 9 | 10 | set -l tmpfile (mktemp $Z_DATA.XXXXXX) 11 | 12 | if test -f $tmpfile 13 | set -l path (string replace --all \\ \\\\ $PWD) 14 | command awk -v path=$path -v now=(date +%s) -F "|" ' 15 | BEGIN { 16 | rank[path] = 1 17 | time[path] = now 18 | } 19 | $2 >= 1 { 20 | if( $1 == path ) { 21 | rank[$1] = $2 + 1 22 | time[$1] = now 23 | } 24 | else { 25 | rank[$1] = $2 26 | time[$1] = $3 27 | } 28 | count += $2 29 | } 30 | END { 31 | if( count > 1000 ) { 32 | for( i in rank ) print i "|" 0.9*rank[i] "|" time[i] # aging 33 | } 34 | else for( i in rank ) print i "|" rank[i] "|" time[i] 35 | } 36 | ' $Z_DATA 2>/dev/null >$tmpfile 37 | 38 | if test ! -z "$Z_OWNER" 39 | chown $Z_OWNER:(id -ng $Z_OWNER) $tmpfile 40 | end 41 | # 42 | # Don't use redirection here as it can lead to a race condition where $Z_DATA is clobbered. 43 | # Note: There is a still a possible race condition where an old version of $Z_DATA is 44 | # read by one instance of Fish before another instance of Fish writes its copy. 45 | # 46 | command mv $tmpfile $Z_DATA 47 | or command rm $tmpfile 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /functions/__z_clean.fish: -------------------------------------------------------------------------------- 1 | function __z_clean -d "Clean up .z file to remove paths no longer valid" 2 | set -l tmpfile (mktemp $Z_DATA.XXXXXX) 3 | 4 | if test -f $tmpfile 5 | while read line 6 | set -l path (string split '|' $line)[1] 7 | test -d $path; and echo $line 8 | end <$Z_DATA >$tmpfile 9 | command mv -f $tmpfile $Z_DATA 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /functions/__z_complete.fish: -------------------------------------------------------------------------------- 1 | function __z_complete -d "add completions" 2 | complete -c $Z_CMD -a "(__z -l | string replace -r '^\\S*\\s*' '')" -f -k 3 | complete -c $ZO_CMD -a "(__z -l | string replace -r '^\\S*\\s*' '')" -f -k 4 | 5 | complete -c $Z_CMD -s c -l clean -d "Cleans out $Z_DATA" 6 | complete -c $Z_CMD -s e -l echo -d "Prints best match, no cd" 7 | complete -c $Z_CMD -s l -l list -d "List matches, no cd" 8 | complete -c $Z_CMD -s p -l purge -d "Purges $Z_DATA" 9 | complete -c $Z_CMD -s r -l rank -d "Searches by rank, cd" 10 | complete -c $Z_CMD -s t -l recent -d "Searches by recency, cd" 11 | complete -c $Z_CMD -s h -l help -d "Print help" 12 | complete -c $Z_CMD -s x -l delete -d "Removes the current directory from $Z_DATA" 13 | end 14 | -------------------------------------------------------------------------------- /man/man1/z.1: -------------------------------------------------------------------------------- 1 | .\" generated with Ronn/v0.7.3 2 | .\" http://github.com/rtomayko/ronn/tree/0.7.3 3 | . 4 | .TH "Z" "1" "August 2019" "" "" 5 | . 6 | .SH "NAME" 7 | \fBz\fR \- jump around 8 | . 9 | .SH "Name" 10 | z \- jump around: port of rupa\'s z 11 | . 12 | .SH "SYNOPSIS" 13 | \fBz [\-cehlprt] string1 string2\.\.\.\fR 14 | . 15 | .br 16 | \fBzo [\-cehlprt] string1 string2\.\.\.\fR 17 | . 18 | .SH "DESCRIPTION" 19 | Port of rupa\'s z: 20 | . 21 | .P 22 | Tracks your most used directories, based on \'frecency\'\. The data is stored in a file located at \fB$Z_DATA\fR\. 23 | . 24 | .P 25 | After a short learning phase, z will take you to the most \'frecent\' directory that matches ALL of the strings given on the command line, in order\. 26 | . 27 | .P 28 | For more details about frecency, see https://github\.com/rupa/z\. 29 | . 30 | .SH "OPTIONS" 31 | . 32 | .TP 33 | \fB\-c\fR, \fB\-\-clean\fR 34 | Removes directories that no longer exist from \fB$Z_DATA\fR\. 35 | . 36 | .TP 37 | \fB\-e\fR, \fB\-\-echo\fR 38 | Prints the best match\. No cd\. 39 | . 40 | .TP 41 | \fB\-h\fR, \fB\-\-help\fR 42 | Show a brief help message\. 43 | . 44 | .TP 45 | \fB\-l\fR, \fB\-\-list\fR 46 | Show a list of matches, and their scores\. No cd\. 47 | . 48 | .TP 49 | \fB\-r\fR, \fB\-\-rank\fR 50 | Match by rank only\. 51 | . 52 | .TP 53 | \fB\-t\fR, \fB\-\-recent\fR 54 | Match by recent only\. 55 | . 56 | .TP 57 | \fB\-x\fR, \fB\-\-delete\fR 58 | Removes the current directory from \fB$Z_DATA\fR\. 59 | . 60 | .SH "EXAMPLES" 61 | . 62 | .TP 63 | \fBz foo\fR 64 | Goes to directory best matching \fBfoo\fR\. 65 | . 66 | .TP 67 | \fBzo foo\fR 68 | Opens file manager of directory best matching \fBfoo\fR\. 69 | . 70 | .TP 71 | \fBz \-t foo\fR 72 | Goes to most recent directory matching \fBfoo\fR\. 73 | . 74 | .TP 75 | \fBz \-x\fR 76 | Removes the current directory from \fB$Z_DATA\fR\. 77 | . 78 | .SH "CONFIGURATION" 79 | . 80 | .TP 81 | \fBset \-U Z_CMD "j"\fR 82 | Change commands to \fBj\fR and \fBjo\fR 83 | . 84 | .TP 85 | \fBset \-U Z_DATA "$HOME/\.foo"\fR 86 | Set data file to \fB$HOME/\.foo\fR 87 | . 88 | .TP 89 | \fBset \-U ZO_METHOD "opencmd"\fR 90 | Runs \fBopencmd dir\fR on \fBzo dir\fR (defaults to \fBopen\fR or \fBxdg\-open\fR) 91 | . 92 | .TP 93 | \fBset \-U Z_OWNER "username"\fR 94 | Ensure data file is owned by \fBusername\fR\. This prevents usage of \fBz\fR with \fBsudo\fR to cause file to be inaccessible in non\-sudo sessions\. 95 | 96 | -------------------------------------------------------------------------------- /man/man1/z.md: -------------------------------------------------------------------------------- 1 | z(1) -- jump around 2 | ================================= 3 | ## Name 4 | 5 | z - jump around: port of rupa's z 6 | 7 | ## SYNOPSIS 8 | 9 | `z [-cehlprt] string1 string2...`
10 | `zo [-cehlprt] string1 string2...` 11 | 12 | ## DESCRIPTION 13 | 14 | Port of rupa's z: 15 | 16 | Tracks your most used directories, based on 'frecency'. The data is 17 | stored in a file located at `$Z_DATA`. 18 | 19 | After a short learning phase, z will take you to the most 'frecent' 20 | directory that matches ALL of the strings given on the command line, 21 | in order. 22 | 23 | For more details about frecency, see https://github.com/rupa/z. 24 | 25 | ## OPTIONS 26 | * `-c`, `--clean`: 27 | Removes directories that no longer exist from `$Z_DATA`. 28 | 29 | * `-e`, `--echo`: 30 | Prints the best match. No cd. 31 | 32 | * `-h`, `--help`: 33 | Show a brief help message. 34 | 35 | * `-l`, `--list`: 36 | Show a list of matches, and their scores. No cd. 37 | 38 | * `-r`, `--rank`: 39 | Match by rank only. 40 | 41 | * `-t`, `--recent`: 42 | Match by recent only. 43 | 44 | * `-x`, `--delete`: 45 | Removes the current directory from `$Z_DATA`. 46 | 47 | ## EXAMPLES 48 | 49 | * `z foo`: 50 | Goes to directory best matching `foo`. 51 | 52 | * `zo foo`: 53 | Opens file manager of directory best matching `foo`. 54 | 55 | * `z -t foo`: 56 | Goes to most recent directory matching `foo`. 57 | 58 | * `z -x`: 59 | Removes the current directory from `$Z_DATA`. 60 | 61 | ## CONFIGURATION 62 | 63 | * `set -U Z_CMD "j"`: 64 | Change commands to `j` and `jo` 65 | 66 | * `set -U Z_DATA "$HOME/.foo"`: 67 | Set data file to `$HOME/.foo` 68 | 69 | * `set -U ZO_METHOD "opencmd"`: 70 | Runs `opencmd dir` on `zo dir` (defaults to `open` or `xdg-open`) 71 | 72 | * `set -U Z_OWNER "username"`: 73 | Ensure data file is owned by `username`. This prevents usage of `z` 74 | with `sudo` to cause file to be inaccessible in non-sudo sessions. 75 | 76 | * `set -p Z_EXCLUDE "regex"`: 77 | Exclude all directories matching the regex from being added to the 78 | z-store in the future. This does not modify the existing store. 79 | 80 | For example `set -p Z_EXCLUDE "^/mnt/workVPN"` will block all paths starting 81 | with `/mnt/workVPN`. `set -P Z_EXCLUDE "^/mnt/workVPN\$"` would exclude 82 | exactly that directory, but not any of `/mnt/workVPN`'s subdirectories. 83 | -------------------------------------------------------------------------------- /test/z.fish: -------------------------------------------------------------------------------- 1 | set -xg pth (mktemp -d) 2 | 3 | set -xg Z_DATA "$pth/.z" 4 | mkdir -p $pth/{foo,bar} 5 | # we can't have | because it is the separator in $Z_DATA 6 | set -xg special '(){}#$%^<>?*"\'\\ & ' 7 | mkdir -p $pth/{foo,bar,$special} 8 | touch $Z_DATA 9 | 10 | function cd_some 11 | z --clean 12 | for i in foo bar $special 13 | cd $pth/$i 14 | end 15 | end 16 | 17 | cd_some 18 | 19 | echo pth $pth >&2 20 | echo Z_DATA $Z_DATA >&2 21 | @test ".z is created" -f $Z_DATA 22 | 23 | @test "Z_CMD is set" ! -z $Z_CMD 24 | 25 | @test "has foo" 0 -eq (grep -q foo $Z_DATA; echo $status) 26 | 27 | @test "has bar" 0 -eq (grep -q bar $Z_DATA; echo $status) 28 | 29 | @test "has special" 0 -eq (fish -c 'grep -qF $special $Z_DATA'; echo $status) 30 | 31 | @test "! has kid" 1 -eq (grep -q kid $Z_DATA; echo $status) 32 | 33 | @test "z --purge" -z (z --purge > /dev/null; cat $Z_DATA) 34 | 35 | @test "z --clean" 1 -eq ( 36 | echo '$pth/invalid_path|1|1501234567' >> $Z_DATA; 37 | z --clean > /dev/null; 38 | grep -q invalid_path $Z_DATA; 39 | echo $status 40 | ) 41 | cd_some 42 | 43 | @test "z -e foo" $pth/foo = (z -e foo) 44 | 45 | @test "! z -e kid" 1 = (z -e kid >/dev/null; echo $status) 46 | 47 | @test "z -h" 0 -eq (z -h | grep -q Usage; echo $status) 48 | 49 | @test "z foo" $pth/foo = (z foo; and echo $PWD) 50 | 51 | @test "z bar" $pth/bar = (z bar; and echo $PWD) 52 | 53 | @test "f oo" $pth/foo = (z f oo; and echo $PWD) 54 | 55 | @test "fo oo" $pth/foo != (z fo oo; and echo $PWD) 56 | 57 | @test "z kid" 1 = (z kid >/dev/null; echo $status) 58 | 59 | @test "z special" 0 -eq (fish -c 'z $special' >/dev/null; echo $status) 60 | 61 | @test "z --list foo" $pth/foo = (z --list foo 2>/dev/null | awk '{ print $2} ') 62 | 63 | @test "z -x works" 1 = (begin; z foo; and z -x; and cd ..; and z foo; end >/dev/null; echo $status) 64 | 65 | rm -rf $pth 66 | --------------------------------------------------------------------------------