summaryrefslogtreecommitdiff
path: root/plugins/fastfile
diff options
context:
space:
mode:
authormapc <musikmichael@web.de>2012-05-06 22:26:12 +0200
committermapc <musikmichael@web.de>2012-05-29 03:24:05 +0200
commit8c18f007131eb242eacae16db85b07f986b08063 (patch)
tree60309becf95dab62d8af4ec019e8d1005f288f9c /plugins/fastfile
parentb7bad0f69b064225a4557667eb1e95d3df8ad819 (diff)
downloadzsh-8c18f007131eb242eacae16db85b07f986b08063.tar.gz
zsh-8c18f007131eb242eacae16db85b07f986b08063.tar.bz2
zsh-8c18f007131eb242eacae16db85b07f986b08063.zip
Enhance handleing of spaces in filenames
Diffstat (limited to 'plugins/fastfile')
-rw-r--r--plugins/fastfile/fastfile.plugin.zsh28
1 files changed, 19 insertions, 9 deletions
diff --git a/plugins/fastfile/fastfile.plugin.zsh b/plugins/fastfile/fastfile.plugin.zsh
index 51e48df5b..775e9483e 100644
--- a/plugins/fastfile/fastfile.plugin.zsh
+++ b/plugins/fastfile/fastfile.plugin.zsh
@@ -32,14 +32,17 @@ default fastfile_var_prefix "ยง"
#
function fastfile() {
test "$2" || 2="."
- 2=$(readlink -f "$2")
- test "$1" || 1="$(basename "$2")"
+ file=$(readlink -f "$2")
+
+ test "$1" || 1="$(basename "$file")"
+ name=$(echo "$1" | tr " " "_")
+
mkdir -p "${fastfile_dir}"
- echo "$2" > "$(fastfile_resolv "$1")"
+ echo "$file" > "$(fastfile_resolv "$name")"
fastfile_sync
- fastfile_print "$1"
+ fastfile_print "$name"
}
#
@@ -85,9 +88,13 @@ function fastfile_print() {
# (=> fastfle_print) for each shortcut
#
function fastfile_ls() {
- for f in $(ls "${fastfile_dir}"); do
- fastfile_print "$f"
- done | column -t
+ for f in "${fastfile_dir}"/*; do
+ file=`basename "$f"` # To enable simpler handeling of spaces in file names
+ varkey=`echo "$file" | tr " " "_"`
+
+ # Special format for colums
+ echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
+ done | column -t -s "|"
}
#
@@ -108,8 +115,11 @@ function fastfile_rm() {
# 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")"
+ for f in "${fastfile_dir}"/*; do
+ file=`basename "$f"` # To enable simpler handeling of spaces in file names
+ varkey=`echo "$file" | tr " " "_"`
+
+ alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
done
}