1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-25 15:20:08 +00:00

Enhance handleing of spaces in filenames

This commit is contained in:
mapc 2012-05-06 22:26:12 +02:00
parent b7bad0f69b
commit 8c18f00713

View file

@ -32,14 +32,17 @@ default fastfile_var_prefix "§"
# #
function fastfile() { function fastfile() {
test "$2" || 2="." test "$2" || 2="."
2=$(readlink -f "$2") file=$(readlink -f "$2")
test "$1" || 1="$(basename "$2")"
test "$1" || 1="$(basename "$file")"
name=$(echo "$1" | tr " " "_")
mkdir -p "${fastfile_dir}" mkdir -p "${fastfile_dir}"
echo "$2" > "$(fastfile_resolv "$1")" echo "$file" > "$(fastfile_resolv "$name")"
fastfile_sync fastfile_sync
fastfile_print "$1" fastfile_print "$name"
} }
# #
@ -85,9 +88,13 @@ function fastfile_print() {
# (=> fastfle_print) for each shortcut # (=> fastfle_print) for each shortcut
# #
function fastfile_ls() { function fastfile_ls() {
for f in $(ls "${fastfile_dir}"); do for f in "${fastfile_dir}"/*; do
fastfile_print "$f" file=`basename "$f"` # To enable simpler handeling of spaces in file names
done | column -t 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 # Generate the aliases for the shortcuts
# #
function fastfile_sync() { function fastfile_sync() {
for f in $(ls "${fastfile_dir}"); do for f in "${fastfile_dir}"/*; do
alias -g "${fastfile_var_prefix}${f}"="$(fastfile_get "$f")" 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 done
} }