b7bad0f69b064225a4557667eb1e95d3df8ad819

Author
mapc <musikmichael@web.de>
Committer
mapc <musikmichael@web.de>
Date

Message

Add the fastfile plugin

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/fastfile/fastfile.plugin.zsh b/plugins/fastfile/fastfile.plugin.zsh
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..51e48df5bff75c0833f961ab7a2fa67ff020fff2
  4--- /dev/null
  5+++ b/plugins/fastfile/fastfile.plugin.zsh
  6@@ -0,0 +1,128 @@
  7+################################################################################
  8+#          FILE:  fastfile.plugin.zsh
  9+#   DESCRIPTION:  oh-my-zsh plugin file.
 10+#        AUTHOR:  Michael Varner (musikmichael@web.de)
 11+#       VERSION:  1.0.0
 12+#
 13+# This plugin adds the ability to on the fly generate and access file shortcuts.
 14+#
 15+################################################################################
 16+
 17+###########################
 18+# Settings 
 19+
 20+# These can be overwritten any time.
 21+# If they are not set yet, they will be
 22+# overwritten with their default values
 23+
 24+default fastfile_dir        "${HOME}/.fastfile/"
 25+default fastfile_var_prefix "§"
 26+
 27+###########################
 28+# Impl
 29+
 30+#
 31+# Generate a shortcut
 32+#
 33+# Arguments:
 34+#    1. name - The name of the shortcut (default: name of the file)
 35+#    2. file - The file or directory to make the shortcut for
 36+# STDOUT:
 37+#    => fastfle_print
 38+#
 39+function fastfile() {
 40+    test "$2" || 2="."
 41+    2=$(readlink -f "$2")
 42+    test "$1" || 1="$(basename "$2")"
 43+
 44+    mkdir -p "${fastfile_dir}"
 45+    echo "$2" > "$(fastfile_resolv "$1")"
 46+
 47+    fastfile_sync
 48+    fastfile_print "$1"
 49+}
 50+
 51+#
 52+# Resolve the location of a shortcut file (the database file, where the value is written!)
 53+#
 54+# Arguments:
 55+#    1. name - The name of the shortcut
 56+# STDOUT:
 57+#   The path
 58+#
 59+function fastfile_resolv() {
 60+    echo "${fastfile_dir}${1}"
 61+}
 62+
 63+#
 64+# Get the real path of a shortcut
 65+#
 66+# Arguments:
 67+#    1. name - The name of the shortcut
 68+# STDOUT:
 69+#    The path
 70+#
 71+function fastfile_get() {
 72+    cat "$(fastfile_resolv "$1")"
 73+}
 74+
 75+#
 76+# Print a shortcut
 77+#
 78+# Arguments:
 79+#    1. name - The name of the shortcut
 80+# STDOUT:
 81+#    Name and value of the shortcut
 82+#
 83+function fastfile_print() {
 84+    echo "${fastfile_var_prefix}${1} -> $(fastfile_get "$1")"
 85+}
 86+
 87+#
 88+# List all shortcuts
 89+#
 90+# STDOUT:
 91+#    (=> fastfle_print) for each shortcut
 92+#
 93+function fastfile_ls() {
 94+    for f in $(ls "${fastfile_dir}"); do
 95+	fastfile_print "$f"
 96+    done | column -t
 97+}
 98+
 99+#
100+# Remove a shortcut
101+#
102+# Arguments:
103+#    1. name - The name of the shortcut (default: name of the file)
104+#    2. file - The file or directory to make the shortcut for
105+# STDOUT: