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.

Test Workflow Lint Workflow Publish Workflow Coverage Version Code Style: black Imports: isort

demo

Table of Contents

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.

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.

Funk Definition Shortcuts

Normally when defining a funk, the provided raw definition (the final contents of the temp file) is inserted directly into the generated function definition. However, funky does try to make some alterations to the original funk definition when doing so is convenient. These funky definition shortcuts can make defining funks faster:

Special cd Funks

A funk definition of the form @./relative/path/to/directory will be automatically changed to

cd /absolute/path/to/directory/"$@" || return 1

Simulate Shell Variables

A funk definition of the form "Some string here..." will be automatically changed to

echo "Some string here..." "$@"

This allows you to use funks to simulate shell variables via command substitution.

The "$@" Special Parameter

This project originally used aliases. The decision to migrate to shell functions was made based on the fact that shell functions are far more capable than aliases. 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 funky by running:

make 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.sh should have been copied to

$XDG_DATA_HOME/funky/funky.sh

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

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

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

Similar Projects

  • desk - A lightweight workspace manager for the shell
  • smartcd - Alter your bash (or zsh) environment as you cd

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.4.1.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfunky-3.4.1-py2.py3-none-any.whl (18.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyfunky-3.4.1.tar.gz.

File metadata

  • Download URL: pyfunky-3.4.1.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for pyfunky-3.4.1.tar.gz
Algorithm Hash digest
SHA256 e8251695d1c19f1c464b9413c5579945362a2527904267d699577e059b0da221
MD5 ba31a36a145ed50226936f23745b4e92
BLAKE2b-256 b45f6064295a7a84316f36d263df3d37c3effbf0f68a55d5263b4244239a25e4

See more details on using hashes here.

File details

Details for the file pyfunky-3.4.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pyfunky-3.4.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for pyfunky-3.4.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 171acbacde08d1443b2b59294b51f2f94757f01efc4c25c4bf50442b04c08e2d
MD5 be42fe2db3715565dd88132570a1fdc2
BLAKE2b-256 f02d9f99f8f349d585d1d6fa4c59d7398cac660210b1acf476705e2990583191

See more details on using hashes here.

Supported by

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