Closed popstas closed 7 years ago
Hello @popstas.
The private
is available in zsh since version 5.2, so I will add about this to README.
Thank you for report.
@ytet5uy4, are you know fast solution (maybe polyfill), how to rewrite your plugin without private
? I'm using my zsh config on several servers including Debian 6 with zsh 4.3.10. I want to fork your plugin and include to my ansible role
Hmm. You should probably use local
instead of private
.
If add the following to init.zsh, might work.
is-at-least 5.2 || private() { local }
Unfortunately, it not work so easy, but it work! local
have other scope.
For example:
is-at-least 5.2 || private() { local }
: "Create cache directory" && () {
if [[ -n $XDG_CACHE_HOME ]]; then
[[ ! -d $XDG_CACHE_HOME ]] && mkdir $XDG_CACHE_HOME
private dir="$XDG_CACHE_HOME/fzf-widgets"
else
private dir="/tmp/fzf-widgets"
fi
# test variable
echo "dir = $dir"
}
Outputs dir =
But:
is-at-least 5.2 || private() { local }
: "Create cache directory" && () {
if [[ -n $XDG_CACHE_HOME ]]; then
[[ ! -d $XDG_CACHE_HOME ]] && mkdir $XDG_CACHE_HOME
dir="$XDG_CACHE_HOME/fzf-widgets"
else
dir="/tmp/fzf-widgets"
fi
# test variable
echo "dir = $dir"
}
Outputs dir = /tmp/fzf-widgets
.
What benefits give using of private
? Maybe better to rewrite for local
?
Debian stable, Ubuntu 16.04, CentOS 7 - all have zsh < 5.2.
Anyway, I will try to do it, do you merge such PR?
I'm sorry, I gave you wrong information. :bowing_man:
The advantages of private
is scope limited than local
.
http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fparam_002fprivate-Module
I'm using only ArchLinux on laptop and server, so I didn't care zsh version.
However I feel I should support zsh versions earlier than 5.2.
If you rewrite private
to local
as follows and send such PR, I merge it.
Before:
: "Create cache directory" && () {
if [[ -n $XDG_CACHE_HOME ]]; then
[[ ! -d $XDG_CACHE_HOME ]] && mkdir $XDG_CACHE_HOME
private dir="$XDG_CACHE_HOME/fzf-widgets"
else
private dir="/tmp/fzf-widgets"
fi
}
After:
: "Create cache directory" && () {
if [[ -n $XDG_CACHE_HOME ]]; then
[[ ! -d $XDG_CACHE_HOME ]] && mkdir $XDG_CACHE_HOME
local dir="$XDG_CACHE_HOME/fzf-widgets"
else
local dir="/tmp/fzf-widgets"
fi
}
https://github.com/robbyrussell/oh-my-zsh/wiki/Coding-style-guide#use-local-variables
NOTE:
: "Create cache directory" && () {
if [[ -n $XDG_CACHE_HOME ]]; then
[[ ! -d $XDG_CACHE_HOME ]] && mkdir $XDG_CACHE_HOME
local dir="$XDG_CACHE_HOME/fzf-widgets"
else
local dir="/tmp/fzf-widgets"
fi
# test variable
echo "dir = $dir"
}
Outputs dir = /tmp/fzf-widgets
.
Fixed in #15
Hello, I'm trying to include widgets with antigen. Widgets loads on macOS, but on Ubuntu outputs many errors begins with: