Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
0caae908
Commit
0caae908
authored
Apr 05, 2020
by
Marc Cornellà
Browse files
lib: speed up slow parts of the lib files; other small fixes
parent
dbd16000
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/completion.zsh
View file @
0caae908
...
@@ -73,4 +73,4 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then
...
@@ -73,4 +73,4 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then
fi
fi
# automatically load bash completion functions
# automatically load bash completion functions
autoload
-U
z
bashcompinit
&&
bashcompinit
autoload
-U
+X
bashcompinit
&&
bashcompinit
lib/functions.zsh
View file @
0caae908
...
@@ -89,7 +89,7 @@ function default() {
...
@@ -89,7 +89,7 @@ function default() {
# 0 if the env variable exists, 3 if it was set
# 0 if the env variable exists, 3 if it was set
#
#
function
env_default
()
{
function
env_default
()
{
((
${
${
(@f)
:-
$(
typeset
+xg
)
}
[(I)
$1
]
}
))
&&
return
0
[[
${
parameters
[
$1
]
}
=
*
-export
*
]]
&&
return
0
export
"
$1
=
$2
"
&&
return
3
export
"
$1
=
$2
"
&&
return
3
}
}
...
...
lib/misc.zsh
View file @
0caae908
...
@@ -3,15 +3,15 @@ autoload -Uz is-at-least
...
@@ -3,15 +3,15 @@ autoload -Uz is-at-least
# *-magic is known buggy in some versions; disable if so
# *-magic is known buggy in some versions; disable if so
if
[[
$DISABLE_MAGIC_FUNCTIONS
!=
true
]]
;
then
if
[[
$DISABLE_MAGIC_FUNCTIONS
!=
true
]]
;
then
for
d
in
$fpath
;
do
for
d
in
$fpath
;
do
if
[[
-e
"
$d
/url-quote-magic"
]]
;
then
if
[[
-e
"
$d
/url-quote-magic"
]]
;
then
if
is-at-least 5.1
;
then
if
is-at-least 5.1
;
then
autoload
-Uz
bracketed-paste-magic
autoload
-Uz
bracketed-paste-magic
zle
-N
bracketed-paste bracketed-paste-magic
zle
-N
bracketed-paste bracketed-paste-magic
fi
fi
autoload
-Uz
url-quote-magic
autoload
-Uz
url-quote-magic
zle
-N
self-insert url-quote-magic
zle
-N
self-insert url-quote-magic
break
break
fi
fi
done
done
fi
fi
...
@@ -25,7 +25,7 @@ env_default 'LESS' '-R'
...
@@ -25,7 +25,7 @@ env_default 'LESS' '-R'
alias
_
=
'sudo '
alias
_
=
'sudo '
## more intelligent acking for ubuntu users
## more intelligent acking for ubuntu users
if
which ack-grep &> /dev/null
;
then
if
((
$+
commands[ack-grep]
))
;
then
alias
afind
=
'ack-grep -il'
alias
afind
=
'ack-grep -il'
else
else
alias
afind
=
'ack -il'
alias
afind
=
'ack -il'
...
...
lib/spectrum.zsh
View file @
0caae908
#! /bin/zsh
# A script to make using 256 colors in zsh less painful.
# A script to make using 256 colors in zsh less painful.
# P.C. Shyamshankar <sykora@lucentbeing.com>
# P.C. Shyamshankar <sykora@lucentbeing.com>
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
...
@@ -6,32 +5,31 @@
...
@@ -6,32 +5,31 @@
typeset
-AHg
FX FG BG
typeset
-AHg
FX FG BG
FX
=(
FX
=(
reset
"%{[00m%}"
reset
"%{[00m%}"
bold
"%{[01m%}"
no-bold
"%{[22m%}"
bold
"%{[01m%}"
no-bold
"%{[22m%}"
italic
"%{[03m%}"
no-italic
"%{[23m%}"
italic
"%{[03m%}"
no-italic
"%{[23m%}"
underline
"%{[04m%}"
no-underline
"%{[24m%}"
underline
"%{[04m%}"
no-underline
"%{[24m%}"
blink
"%{[05m%}"
no-blink
"%{[25m%}"
blink
"%{[05m%}"
no-blink
"%{[25m%}"
reverse
"%{[07m%}"
no-reverse
"%{[27m%}"
reverse
"%{[07m%}"
no-reverse
"%{[27m%}"
)
)
for
color
in
{
000..255
}
;
do
for
color
in
{
000..255
}
;
do
FG[
$color
]=
"%{[38;5;
${
color
}
m%}"
FG[
$color
]=
"%{[38;5;
${
color
}
m%}"
BG[
$color
]=
"%{[48;5;
${
color
}
m%}"
BG[
$color
]=
"%{[48;5;
${
color
}
m%}"
done
done
ZSH_SPECTRUM_TEXT
=
${
ZSH_SPECTRUM_TEXT
:-
Arma
virumque cano Troiae qui primus ab oris
}
# Show all 256 colors with color number
# Show all 256 colors with color number
function
spectrum_ls
()
{
function
spectrum_ls
()
{
local
ZSH_SPECTRUM_TEXT
=
${
ZSH_SPECTRUM_TEXT
:-
Arma
virumque cano Troiae qui primus ab oris
}
for
code
in
{
000..255
}
;
do
for
code
in
{
000..255
}
;
do
print
-P
--
"
$code
:
%{
$FG
[
$code
]
%}
$ZSH_SPECTRUM_TEXT
%{
$reset_color
%}"
print
-P
--
"
$code
:
$FG
[
$code
]
$ZSH_SPECTRUM_TEXT
%{
$reset_color
%}"
done
done
}
}
# Show all 256 colors where the background is set to specific color
# Show all 256 colors where the background is set to specific color
function
spectrum_bls
()
{
function
spectrum_bls
()
{
local
ZSH_SPECTRUM_TEXT
=
${
ZSH_SPECTRUM_TEXT
:-
Arma
virumque cano Troiae qui primus ab oris
}
for
code
in
{
000..255
}
;
do
for
code
in
{
000..255
}
;
do
print
-P
--
"
$code
:
%{
$BG
[
$code
]
%}
$ZSH_SPECTRUM_TEXT
%{
$reset_color
%}"
print
-P
--
"
$code
:
$BG
[
$code
]
$ZSH_SPECTRUM_TEXT
%{
$reset_color
%}"
done
done
}
}
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