Convert Figma logo to code with AI

rupa logoz

z - jump around

16,339
1,171
16,339
103

Top Related Projects

64,567

:cherry_blossom: A command-line fuzzy finder

22,310

A smarter cd command. Supports all major shells.

16,229

A cd command that learns - easily navigate directories from the command line

5,905

Command-line productivity booster, offers quick access to files and directories, inspired by autojump, z and v.

2,996

:zap: A new cd command that helps you navigate faster by learning your habits.

🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.

Quick Overview

The rupa/z project is a command-line tool that helps users navigate their file system more efficiently by providing a way to quickly jump to frequently used directories. It uses a ranking system to determine the most relevant directories based on usage history.

Pros

  • Improved Navigation: z allows users to quickly navigate to frequently used directories, reducing the time and effort required to move between different parts of the file system.
  • Intelligent Directory Ranking: The tool uses a ranking system to determine the most relevant directories, making it easier to find the desired location.
  • Cross-Platform Compatibility: z is compatible with various operating systems, including Linux, macOS, and Windows, making it a versatile tool.
  • Customizable Behavior: Users can customize the behavior of z to suit their preferences, such as adjusting the ranking algorithm or setting up aliases.

Cons

  • Requires Initial Setup: Users need to set up z by adding it to their shell configuration, which may be a barrier for some users.
  • Dependency on Shell: z is a shell-based tool, so it may not be as accessible to users who prefer a graphical user interface (GUI) for file management.
  • Limited Functionality: While z is a powerful tool for navigating the file system, it may not provide the full range of features that some users might expect from a file management tool.
  • Potential Performance Issues: In large file systems with many directories, the ranking algorithm used by z may slow down the navigation process.

Code Examples

N/A (This is not a code library)

Getting Started

N/A (This is not a code library)

Competitor Comparisons

64,567

:cherry_blossom: A command-line fuzzy finder

Pros of fzf

  • fzf provides a more feature-rich and customizable fuzzy finder experience compared to z.
  • fzf supports a wider range of use cases, including file/directory selection, command history, and more.
  • fzf has a larger and more active community, with more contributors and a more frequent release cycle.

Cons of fzf

  • fzf has a steeper learning curve and requires more configuration to get the most out of it.
  • fzf may be overkill for users who only need basic directory navigation functionality.
  • fzf has a larger codebase and may have a higher resource footprint compared to z.

Code Comparison

fzf:

# Search for a file
fzf

# Search for a command in history
fzf --history

# Use fzf with vim
vim $(fzf)

z:

# Jump to a frequently used directory
z directory_name

# List frequently used directories
z -l

# Open a directory in the current shell
z directory_name && ls
22,310

A smarter cd command. Supports all major shells.

Pros of zoxide

  • zoxide is written in Rust, which can provide better performance and security compared to the shell script-based z.
  • zoxide supports more advanced features like fuzzy search, directory ranking, and directory exclusion.
  • zoxide has a more active development community with regular updates and bug fixes.

Cons of zoxide

  • zoxide may have a steeper learning curve for users familiar with the simplicity of z.
  • zoxide requires the installation of a Rust runtime, which may not be available on all systems by default.
  • zoxide may have a larger binary size compared to the lightweight z script.

Code Comparison

z (rupa/z):

_z() {
    [ "$#" -gt 2 ] && return
    if [ "$#" -eq 2 ]; then
        cd -- "$2"
    else
        cd -- "$(
            [ -z "$ZV" ] && echo "$PWD" || echo "$ZV"
        )"
    fi
}

zoxide (ajeetdsouza/zoxide):

fn main() {
    let matches = App::new("zoxide")
        .version(env!("CARGO_PKG_VERSION"))
        .about("A fast cd command that learns your habits")
        .arg(
            Arg::with_name("query")
                .help("Directory to jump to")
                .index(1)
                .required(false),
        )
        .get_matches();

    let query = matches.value_of("query");
    zoxide::run(query);
}
16,229

A cd command that learns - easily navigate directories from the command line

Pros of Autojump

  • Autojump provides a more intuitive and user-friendly interface for navigating directories, with a simple j <directory> command to jump to a frequently used directory.
  • The project has a larger user base and more active development, with regular updates and bug fixes.
  • Autojump supports a wider range of platforms, including Linux, macOS, and Windows, making it more accessible to a broader audience.

Cons of Autojump

  • Autojump requires an additional installation step, as it is a separate tool from the shell, whereas z is a shell function that is typically already available.
  • The configuration and customization options in Autojump may be less extensive compared to z, which is more flexible and can be easily integrated into a user's shell environment.

Code Comparison

z (rupa/z):

_z() {
    [ "$#" -eq 0 ] && return
    local dir
    dir="$(command awk -v t="$(date '+%Y %m %d %H %M %S')" -F"|" '
        $2 >= t-86400*31 { $1=gensub(/\/+/, " ", "g", $1); print $1 }' ~/.z 2>/dev/null | \
        sort -nr | head -n 1)"
    [ "$dir" ] && cd "$dir"
}

Autojump (wting/autojump):

def get_path(self, name):
    """
    Returns the full path for a given name.
    """
    try:
        return self.db[name]
    except KeyError:
        return None
5,905

Command-line productivity booster, offers quick access to files and directories, inspired by autojump, z and v.

Pros of fasd

  • fasd supports a wider range of shells, including Bash, Zsh, Fish, and Tcsh, while z is primarily focused on Zsh.
  • fasd provides a more flexible and customizable interface for navigating directories, with support for various scoring algorithms and weighting options.
  • fasd has a larger user base and more active development, with more frequent updates and bug fixes.

Cons of fasd

  • fasd may have a steeper learning curve compared to z, as it offers more advanced features and configuration options.
  • fasd's scoring algorithm and weighting system can be more complex to understand and configure, especially for users who prefer a simpler approach.
  • fasd may have a slightly higher resource footprint compared to z, as it needs to maintain a database of visited directories.

Code Comparison

fasd:

# Jump to a frequently used directory
fasd_cd() {
    local dir="$(fasd -d "$@" | fzf --algo=v1 --tac --height 40% --preview 'tree -C {} | head -200')"
    [ -d "$dir" ] && cd "$dir"
}

z:

# Jump to a frequently used directory
z() {
    [ $# -gt 0 ] && _z "$*" && return
    cd "$(_z -l 2>&1 | fzf --height 40% --nth 2.. --reverse --inline-info +s --tac --query "$*" | sed 's/^[^ ]*  *//')"
}
2,996

:zap: A new cd command that helps you navigate faster by learning your habits.

Pros of z.lua

  • z.lua is written in Lua, which is a lightweight and fast scripting language, making it potentially more efficient than the original z written in Bash.
  • z.lua provides a more modern and feature-rich interface, with support for fuzzy search, tab completion, and more.
  • The project is actively maintained, with regular updates and improvements.

Cons of z.lua

  • z.lua may have a steeper learning curve for users familiar with the original z, as the interface and syntax are different.
  • The Lua ecosystem may not be as widely adopted as Bash, potentially limiting the availability of third-party tools and integrations.
  • The performance benefits of Lua may not be significant for many users, and the added complexity of a separate language may be unnecessary.

Code Comparison

z.lua:

function z(...)
    local argc = select('#', ...)
    local argv = {...}
    local opts = {}

    for i = 1, argc do
        local arg = argv[i]
        if arg:sub(1, 1) == '-' then
            opts[arg:sub(2)] = true
        else
            table.insert(opts, arg)
        end
    end

    -- ...
end

z (Bash):

z() {
    [ "$#" -gt 0 ] || return
    local dir="$(
        (
            cd "$HOME/.z"
            scala -e "println(com.github.rupa.z.Cli.run(Array(${@q@})))"
        )
    )"
    [ "$dir" ] && cd "$dir"
}

🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.

Pros of zsh-autocomplete

  • Provides more advanced autocomplete features, such as fuzzy matching and case-insensitive completion.
  • Supports a wider range of commands and file types, including Git, Docker, and more.
  • Offers a more customizable and configurable autocomplete experience.

Cons of zsh-autocomplete

  • May have a larger footprint and slower performance compared to z, as it is a more feature-rich plugin.
  • Requires additional configuration and setup to integrate with the user's existing zsh environment.
  • May not be as widely adopted or have the same level of community support as z.

Code Comparison

z:

_z() {
  local datafile="$HOME/.z"
  if [[ -f "$datafile" ]]; then
    # add entries
    if [[ "$1" == "--add" ]]; then
      shift
      # $HOME isn't whose location we care about, but rather the location itself
      local tempfile="$(mktemp $datafile.XXXXXX)"
      while read line; do
        if [[ $line != "$*" ]]; then
          echo $line
        fi
      done < "$datafile" > "$tempfile"
      echo "$*" >> "$tempfile"
      mv -f "$tempfile" "$datafile"
    # tab completion
    elif [[ "$1" == "--complete" ]]; then
      cat "$datafile" | awk -F"|" '{print $2}' | fzf --height 40% --nth 2.. --query "$2" --select-1 --exit-0
    else
      # list/go
      cat "$datafile" | while read line; do
        echo $line | awk -F "|" '{print $2}'
      done | fzf --height 40% --nth 2.. --query "$1" --select-1 --exit-0
    fi
  fi
}

zsh-autocomplete:

_zsh_autosuggest_highlight_style() {
  typeset -g ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE
  ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE-fg=8}"
}

_zsh_autosuggest_highlight_apply() {
  if [[ -n "$BUFFER" ]]; then
    typeset -g RBUFFER="$(_zsh_autosuggest_escape_command "$BUFFER")"
    typeset -g LBUFFER="$BUFFER"
    typeset -g CURSOR=$#LBUFFER
    _zsh_autosuggest_highlight_reset
    _zsh_autosuggest_highlight_style
    _zsh_autosuggest_highlight_apply_suggestion
  fi
}

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Z(1) User Commands Z(1)

NAME z - jump around

SYNOPSIS z [-chlrtx] [regex1 regex2 ... regexn]

AVAILABILITY bash, zsh

DESCRIPTION Tracks your most used directories, based on 'frecency'.

   After  a  short  learning  phase, z will take you to the most 'frecent'
   directory that matches ALL of the regexes given on the command line, in
   order.

   For example, z foo bar would match /foo/bar but not /bar/foo.

OPTIONS -c restrict matches to subdirectories of the current directory

   -e     echo the best match, don't cd

   -h     show a brief help message

   -l     list only

   -r     match by rank only

   -t     match by recent access only

   -x     remove the current directory from the datafile

EXAMPLES z foo cd to most frecent dir matching foo

   z foo bar     cd to most frecent dir matching foo, then bar

   z -r foo      cd to highest ranked dir matching foo

   z -t foo      cd to most recently accessed dir matching foo

   z -l foo      list all dirs matching foo (by frecency)

NOTES Installation: Put something like this in your $HOME/.bashrc or $HOME/.zshrc:

          . /path/to/z.sh

   cd around for a while to build up the db.

   PROFIT!!

   Optionally:
          Set $_Z_CMD to change the command name (default z).
          Set $_Z_DATA to change the datafile (default $HOME/.z).
          Set  $_Z_MAX_SCORE  lower  to  age  entries  out faster (default
          9000).
          Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
          Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd  your-
          self.
          Set $_Z_EXCLUDE_DIRS to an array of directory trees to  exclude.
          Set $_Z_OWNER to allow usage when in 'sudo -s' mode.
          (These  settings  should  go  in  .bashrc/.zshrc before the line
          added above.)
          Install the provided man page z.1  somewhere  in  your  MANPATH,
          like /usr/local/man/man1.

Aging: The rank of directories maintained by z undergoes aging based on a sim- ple formula. The rank of each entry is incremented every time it is accessed. When the sum of ranks is over 9000, all ranks are multiplied by 0.99. Entries with a rank lower than 1 are forgotten.

Frecency: Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted rank that depends on how often and how recently something occurred. As far as I know, Mozilla came up with the term.

   To z, a directory that has low ranking but has been  accessed  recently
   will  quickly  have  higher rank than a directory accessed frequently a
   long time ago.

   Frecency is determined at runtime.

Common: When multiple directories match all queries, and they all have a common prefix, z will cd to the shortest matching directory, without regard to priority. This has been in effect, if undocumented, for quite some time, but should probably be configurable or reconsidered.

Tab Completion: z supports tab completion. After any number of arguments, press TAB to complete on directories that match each argument. Due to limitations of the completion implementations, only the last argument will be com- pleted in the shell.

   Internally, z decides you've requested a completion if the  last  argu-
   ment  passed  is  an  absolute  path to an existing directory. This may
   cause unexpected behavior if the last argument to z begins with /.

ENVIRONMENT A function _z() is defined.

   The contents of the variable $_Z_CMD is aliased to _z 2>&1. If not set,
   $_Z_CMD defaults to z.

   The  environment  variable $_Z_DATA can be used to control the datafile
   location. If it is not defined, the location defaults to $HOME/.z.

   The environment variable $_Z_NO_RESOLVE_SYMLINKS can be set to  prevent
   resolving  of  symlinks.  If  it  is  not  set,  symbolic links will be
   resolved when added to the datafile.

   In bash, z appends a command to the PROMPT_COMMAND environment variable
   to maintain its database. In zsh, z appends a function _z_precmd to the
   precmd_functions array.

   The environment variable $_Z_NO_PROMPT_COMMAND can be set if  you  want
   to handle PROMPT_COMMAND or precmd yourself.

   The  environment  variable  $_Z_EXCLUDE_DIRS  can be set to an array of
   directory trees to exclude from tracking.  $HOME  is  always  excluded.
   Directories must be full paths without trailing slashes.

   The  environment  variable  $_Z_OWNER  can  be set to your username, to
   allow usage of z when your sudo environment keeps $HOME set.

FILES Data is stored in $HOME/.z. This can be overridden by setting the $_Z_DATA environment variable. When initialized, z will raise an error if this path is a directory, and not function correctly.

   A man page (z.1) is provided.

SEE ALSO regex(7), pushd, popd, autojump, cdargs

   Please file bugs at https://github.com/rupa/z/

z January 2013 Z(1)