Skip to main content

Funky makes ZSH shell functions more powerful and easier to manage.

Project description

funky Tweet

Funky takes shell functions to the next level by making them easier to define, more flexible, and more interactive.

Build Status codecov License: MIT

demo

Usage

Funks are manipulated using the funky and gfunky commands. These commands have the same user interface, which is specified in the Command-line Interface section. The difference between the two commands is treated in the Local vs Global section.

Command-line Interface

usage: funky [-h] [-d] [-v] [--version] [-c] [-a ALIAS] [-r [ALIAS]]
             [-e ALIAS] [-R OLD NEW]
             [ALIAS]

Funky makes ZSH shell functions more powerful and easier to manage.

optional arguments:
  -h, --help     show this help message and exit
  -d, --debug    Enable debug mode.
  -v, --verbose  Enable verbose output.
  --version      show program's version number and exit
  -c, --color    Colorize output.

Action Commands:
  All of these options act on the current set of local funks in some way. If
  no action command is provided, the default action is to display all of the
  local funks currently in scope. These commands are mutually exclusive.

  -a ALIAS       Add a new funk.
  -r [ALIAS]     Remove an existing funk. Or (if ALIAS is not given) remove
                 all funks defined in this directory.
  -e ALIAS       Edit an existing funk.
  -R OLD NEW     Rename an existing funk. OLD funk is renamed to NEW.
  ALIAS          When no action command is specified, the default action is to
                 display existing funks. An funk name (ALIAS) can optionally
                 be provided as an argument to display only ALIAS. If ALIAS
                 ends in two periods ('..'), it is treated as a prefix instead
                 of an exact match: all funks that start with ALIAS (not
                 including the trailing '..') will be displayed.

Local vs Global

Local funks are stored using a hidden database file that is located in the same directory where the funk was created. These can be manipulated using the action command options described above. Once created, a local funk can be used just like any other command or normal funk---as long as you have activated the provided shell extension (see Additional Install Steps) and are inside of the directory where the local funk was originally defined.

Global funks, on the other hand, are stored in your home directory (/home/<user>) and can be used from any directory. Local funks can be used to override global funk definitions.

Local and global funks can be manipulated (created, removed, edited, renamed, etc.) by using the funky and gfunky commands, respectively.

Aliases vs Funks

This project originally used funks. The decision to migrate to shell functions was made based on the fact that shell functions are far more capable than funks. Moreover, there is very little benefit to using aliases over shell functions.

With that said, actual aliases do have one appeal over shell functions. When you use an alias, any arguments that you pass to it are automatically passed to the command definition (at runtime, aliases are just substituted with their definitions). For the purpose of emulating this behavior when it would typically be desired, a funk defined using a single-line command definition that does NOT already contain argument variables (e.g. does not contain $0, $1, ..., $9, $*, or $@) will automatically have the "$@" special parameter appended to its definition. This allows for the same automatic argument handling that you would expect from an alias.

See the official Bash docs for more information on Bash's special parameters.

Installation

Using pip to Install

To install funky, run this command in your terminal:

$ pip install pyfunky

This is the preferred method to install funky, as it will always install the most recent stable release.

If you don't have pip installed, this Python installation guide can guide you through the process.

Building from Source

You can either clone the public repository:

$ git clone git://github.com/bbugyi200/funky

Or download the tarball:

$ curl  -OL https://github.com/bbugyi200/funky/tarball/master

Once you have a copy of the source, you can install it with:

$ python setup.py install

Additional Installation Steps

For the best experience, funky needs to be integrated into your shell environment using the provided shell script.

A shell script by the name of funky.zsh should have been copied to

$XDG_DATA_HOME/funky/funky.zsh

during the installation process (it can also be found here). You can integrate funky into your shell by sourcing the funky.zsh script into your shell's configuration file. Assuming the script was copied to ~/.local/share/funky/funky.zsh (its default location), for example, you would add the following line to your .zshrc:

[ -f ~/.local/share/funky/funky.zsh ] && source ~/.local/share/funky/funky.zsh

If you install funky with root permissions, the funky.zsh script will instead be installed to /usr/share/funky/funky.zsh.

Similar Projects

  • Desk - A lightweight workspace manager for the shell

Contributions

Pull requests are welcome. See CONTRIBUTING.md for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfunky-3.0.5.tar.gz (21.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page