• Stars
    star
    641
  • Rank 70,212 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 7 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

funky Tweet

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

Project Version Python Versions Package Health

Linter: pylint Linter: flake8 Types: mypy Docstrings: pydocstyle Code Style: black Imports: isort

Test Workflow Lint Workflow Publish Workflow Coverage

demo

Table of Contents

Installation

Using pipx to Install (preferred)

This package could be installed using pip like any other Python package (in fact, see the section below this one for instructions). Given that we only need this package's entry points (e.g. the funky command), however, we recommend that pipx be used instead (replace SHELL with either bash or zsh):

# install and setup pipx
python3 -m pip install --user pipx
python3 -m pipx ensurepath

# install and setup funky
pipx install pyfunky
funky --setup-shell SHELL

Using pip to Install

To install funky using pip, run the following commands in your terminal (replace SHELL with either bash or zsh):

python3 -m pip install --user pyfunky  # install funky
funky --setup-shell SHELL  # hook funky into your shell

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

The last thing you need to do is hook funky into your preferred shell, which can be accomplished with the following command (replace SHELL with either bash or zsh):

funky --setup-shell SHELL

Usage

Funks are manipulated using the funky and gfunky commands. These commands have the same user interface. 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 options described in the demo above (run funky -h to see descriptions of these options). Once created, a local funk can be used just like any other command or normal funk as long as you 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.

Articles / Blog Posts

With the goal of listing alternative sources of documentation / tutorials, this section will be used to track any articles or blog posts which mention funky:

Similar Projects

  • desk - A lightweight workspace manager for the shell.
  • smartcd - Alter your bash (or zsh) environment as you cd.
  • direnv - is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory.

Contributions

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

More Repositories

1

cookie

A Template-based File Generator. Like cookiecutter but works with file templates instead of project templates.
Shell
283
star
2

old_dotfiles

My Config Files
Shell
10
star
3

scripts

Scripts... Many of which are dependencies for my dotfiles repository
Shell
7
star
4

pywalkie

A two-way walkie-talkie command-line application.
Python
6
star
5

result

A fully type-annotated Rust-like Result type for Python.
Python
5
star
6

WumpusWorld

Stuart Russel and Peter Norvig's Wumpus World environment...
Python
5
star
7

greatday

Don't have a good day... Have a great day.
Python
4
star
8

cc-python

This repository contains the cookiecutter that I use for all of my Python projects.
Shell
4
star
9

python-tools

Miscellaneous tools / executable scripts.
Shell
2
star
10

dotfiles

My configuration files... These files are managed / installed on each of my development machines by chezmoi.
Vim Snippet
2
star
11

basher

CLI tool that acts as a basic package manager for shell libraries.
Makefile
2
star
12

tmux-utils

Helper scripts for working with tmux more efficiently.
Shell
2
star
13

python-dummy

Dummy python project used to test the cc-python cookiecutter.
Makefile
2
star
14

python-lib

Overly general Python library used when no other library is a good fit.
Python
2
star
15

bashlibs

Bash Libraries that I use in Multiple Projects
Shell
2
star
16

zorg

The zettel note manager of the future.
Python
2
star
17

logrus

Better logging made easy with support for structlog and the standard logging module.
Python
1
star
18

magodo

A Python library for working with the todo.txt format, with some magic thrown in.
Python
1
star
19

shmgr

CLI tool that helps manage shell libraries.
Python
1
star
20

django

My Hello World project for Django
Python
1
star
21

FlaskWebsite

My old personal website. Built using Flask microframework.
HTML
1
star
22

shellman

CLI tool that acts as a basic package manager for shell libraries.
1
star
23

tman

Torrent manager enables you to download / seed your torrents on your own schedule.
Shell
1
star
24

vimala

Python library for working with command-line editors (like vim).
Shell
1
star
25

logutils

Better logging made easy with support for structlog and the standard logging module.
Python
1
star
26

shv

Take control of your shell history once and for all.
Rust
1
star
27

hush

A Python library that helps manage secrets using tools specified by plugin hooks.
Python
1
star
28

clap

(C)ommand (L)ine (A)rgument (P)arsing... A thin wrapper around the standard argparse library.
Python
1
star
29

cldr

changelog driven releases (CLDR)...
Python
1
star
30

sync-or-swim

Sync data files across all of your machines (tinyurl.com/sync-or-swim)
Shell
1
star