Diff
1diff --git a/plugins/fastfile/README.md b/plugins/fastfile/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..37f5b2f5359f9a3f6b177a3655309e6fe35e8bab
4--- /dev/null
5+++ b/plugins/fastfile/README.md
6@@ -0,0 +1,84 @@
7+# Fastfile plugin
8+
9+This plugin adds a way to reference certain files or folders used frequently using
10+a global alias or shortcut.
11+
12+To use it, add `fastfile` to the plugins array in your zshrc file:
13+```zsh
14+plugins=(... fastfile)
15+```
16+
17+## Usage
18+
19+Example: you access folder `/code/project/backend/database` very frequently.
20+
21+First, generate a shortcut with the name `pjdb`:
22+```zsh
23+$ fastfile pjdb /code/project/backend/database
24+```
25+
26+Next time you want to access it, use `§pjdb`. For example:
27+```zsh
28+$ cd §pjdb
29+$ subl §pjdb
30+```
31+where § is the fastfile prefix (see [below](#options) for how to change).
32+
33+**Note:** shortcuts with spaces in the name are assigned a global alias
34+where the spaces have been substituted with underscores (`_`). For example:
35+a shortcut named `"hello world"` corresponds with `§hello_world`.
36+
37+
38+## Functions
39+
40+- `fastfile <shortcut_name> <path/to/file/or/folder>`: generate a shortcut.
41+
42+- `fastfile_print <shortcut_name>`: prints a shortcut, with the format
43+ `<prefix><shortcut_name> -> <shortcut_path>`.
44+
45+- `fastfile_ls`: lists all shortcuts.
46+
47+- `fastfile_rm <shortcut_name> `: remove a shortcut.
48+
49+- `fastfile_sync`: generates the global aliases for the shortcuts.
50+
51+
52+### Internal functions
53+
54+- `fastfile_resolv <shortcut_name>`: resolves the location of the shortcut
55+ file, i.e., the file in the fastfile directory where the shortcut path
56+ is stored.
57+
58+- `fastfile_get <shortcut_name>`: get the real path of the shortcut.
59+
60+
61+## Aliases
62+
63+| Alias | Function |
64+|--------|------------------|
65+| ff | `fastfile` |
66+| ffp | `fastfile_print` |
67+| ffrm | `fastfile_rm` |
68+| ffls | `fastfile_ls` |
69+| ffsync | `fastfile_sync` |
70+
71+
72+## Options
73+
74+These are options you can set to change certain parts of the plugin. To change
75+them, add `<variable>=<value>` to your zshrc file, before Oh My Zsh is sourced.
76+For example: `fastfile_var_prefix='@'`.
77+
78+- `fastfile_var_prefix`: prefix for the global aliases created. Controls the prefix of the
79+ created global aliases.
80+ **Default:** `§` (section sign), easy to type in a german keyboard via the combination
81+ [`⇧ Shift`+`3`](https://en.wikipedia.org/wiki/German_keyboard_layout#/media/File:KB_Germany.svg),
82+ or using `⌥ Option`+`6` in macOS.
83+
84+- `fastfile_dir`: directory where the fastfile shortcuts are stored. Needs to end
85+ with a trailing slash.
86+ **Default:** `$HOME/.fastfile/`.
87+
88+## Author
89+
90+- [Karolin Varner](https://github.com/koraa)
91diff --git a/plugins/fastfile/fastfile.plugin.zsh b/plugins/fastfile/fastfile.plugin.zsh
92index 775e9483e35c045b8cf6c6fbcefc042466d28feb..a4229e4c20733c8d5352a92cd15f277bd6892148 100644
93--- a/plugins/fastfile/fastfile.plugin.zsh
94+++ b/plugins/fastfile/fastfile.plugin.zsh
95@@ -1,15 +1,5 @@
96-################################################################################
97-# FILE: fastfile.plugin.zsh
98-# DESCRIPTION: oh-my-zsh plugin file.
99-# AUTHOR: Michael Varner (musikmichael@web.de)
100-# VERSION: 1.0.0
101-#
102-# This plugin adds the ability to on the fly generate and access file shortcuts.
103-#
104-################################################################################
105-
106 ###########################
107-# Settings
108+# Settings
109
110 # These can be overwritten any time.
111 # If they are not set yet, they will be
112@@ -33,7 +23,7 @@ default fastfile_var_prefix "§"
113 function fastfile() {
114 test "$2" || 2="."
115 file=$(readlink -f "$2")
116-
117+
118 test "$1" || 1="$(basename "$file")"
119 name=$(echo "$1" | tr " " "_")
120
121@@ -51,7 +41,7 @@ function fastfile() {
122 # Arguments:
123 # 1. name - The name of the shortcut
124 # STDOUT:
125-# The path
126+# The path to the shortcut file
127 #
128 function fastfile_resolv() {
129 echo "${fastfile_dir}${1}"
130@@ -88,12 +78,12 @@ function fastfile_print() {
131 # (=> fastfle_print) for each shortcut
132 #
133 function fastfile_ls() {
134- for f in "${fastfile_dir}"/*; do
135- file=`basename "$f"` # To enable simpler handeling of spaces in file names
136- varkey=`echo "$file" | tr " " "_"`
137+ for f in "${fastfile_dir}"/*; do
138+ file=`basename "$f"` # To enable simpler handeling of spaces in file names
139+ varkey=`echo "$file" | tr " " "_"`
140
141- # Special format for colums
142- echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
143+ # Special format for colums
144+ echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
145 done | column -t -s "|"
146 }
147
148@@ -102,7 +92,6 @@ function fastfile_ls() {
149 #
150 # Arguments:
151 # 1. name - The name of the shortcut (default: name of the file)
152-# 2. file - The file or directory to make the shortcut for
153 # STDOUT:
154 # => fastfle_print
155 #
156@@ -115,11 +104,11 @@ function fastfile_rm() {
157 # Generate the aliases for the shortcuts
158 #
159 function fastfile_sync() {
160- for f in "${fastfile_dir}"/*; do
161- file=`basename "$f"` # To enable simpler handeling of spaces in file names
162- varkey=`echo "$file" | tr " " "_"`
163+ for f in "${fastfile_dir}"/*; do
164+ file=`basename "$f"` # To enable simpler handeling of spaces in file names
165+ varkey=`echo "$file" | tr " " "_"`
166
167- alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
168+ alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
169 done
170 }
171
172@@ -133,6 +122,6 @@ alias ffls=fastfile_ls
173 alias ffsync=fastfile_sync
174
175 ##################################
176-# Init
177+# Init
178
179-fastfile_sync
180+fastfile_sync