Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
b7bad0f6
Commit
b7bad0f6
authored
May 05, 2012
by
mapc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the fastfile plugin
parent
1120f973
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
0 deletions
+129
-0
fastfile.plugin.zsh
plugins/fastfile/fastfile.plugin.zsh
+129
-0
No files found.
plugins/fastfile/fastfile.plugin.zsh
0 → 100644
View file @
b7bad0f6
################################################################################
# FILE: fastfile.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Michael Varner (musikmichael@web.de)
# VERSION: 1.0.0
#
# This plugin adds the ability to on the fly generate and access file shortcuts.
#
################################################################################
###########################
# Settings
# These can be overwritten any time.
# If they are not set yet, they will be
# overwritten with their default values
default fastfile_dir
"
${
HOME
}
/.fastfile/"
default fastfile_var_prefix
"§"
###########################
# Impl
#
# Generate a shortcut
#
# Arguments:
# 1. name - The name of the shortcut (default: name of the file)
# 2. file - The file or directory to make the shortcut for
# STDOUT:
# => fastfle_print
#
function
fastfile
()
{
test
"
$2
"
||
2
=
"."
2
=
$(
readlink
-f
"
$2
"
)
test
"
$1
"
||
1
=
"
$(
basename
"
$2
"
)
"
mkdir
-p
"
${
fastfile_dir
}
"
echo
"
$2
"
>
"
$(
fastfile_resolv
"
$1
"
)
"
fastfile_sync
fastfile_print
"
$1
"
}
#
# Resolve the location of a shortcut file (the database file, where the value is written!)
#
# Arguments:
# 1. name - The name of the shortcut
# STDOUT:
# The path
#
function
fastfile_resolv
()
{
echo
"
${
fastfile_dir
}${
1
}
"
}
#
# Get the real path of a shortcut
#
# Arguments:
# 1. name - The name of the shortcut
# STDOUT:
# The path
#
function
fastfile_get
()
{
cat
"
$(
fastfile_resolv
"
$1
"
)
"
}
#
# Print a shortcut
#
# Arguments:
# 1. name - The name of the shortcut
# STDOUT:
# Name and value of the shortcut
#
function
fastfile_print
()
{
echo
"
${
fastfile_var_prefix
}${
1
}
->
$(
fastfile_get
"
$1
"
)
"
}
#
# List all shortcuts
#
# STDOUT:
# (=> fastfle_print) for each shortcut
#
function
fastfile_ls
()
{
for
f
in
$(
ls
"
${
fastfile_dir
}
"
)
;
do
fastfile_print
"
$f
"
done
| column
-t
}
#
# Remove a shortcut
#
# Arguments:
# 1. name - The name of the shortcut (default: name of the file)
# 2. file - The file or directory to make the shortcut for
# STDOUT:
# => fastfle_print
#
function
fastfile_rm
()
{
fastfile_print
"
$1
"
rm
"
$(
fastfile_resolv
"
$1
"
)
"
}
#
# Generate the aliases for the shortcuts
#
function
fastfile_sync
()
{
for
f
in
$(
ls
"
${
fastfile_dir
}
"
)
;
do
alias
-g
"
${
fastfile_var_prefix
}${
f
}
"
=
"
$(
fastfile_get
"
$f
"
)
"
done
}
##################################
# Shortcuts
alias
ff
=
fastfile
alias
ffp
=
fastfile_print
alias
ffrm
=
fastfile_rm
alias
ffls
=
fastfile_ls
alias
ffsync
=
fastfile_sync
##################################
# Init
fastfile_sync
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment