Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
53c9661b
Unverified
Commit
53c9661b
authored
Oct 05, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(chucknorris): refresh plugin code
parent
e5b9b800
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
23 deletions
+17
-23
README.md
plugins/chucknorris/README.md
+1
-3
chucknorris.plugin.zsh
plugins/chucknorris/chucknorris.plugin.zsh
+16
-20
No files found.
plugins/chucknorris/README.md
View file @
53c9661b
# chucknorris
# chucknorris
Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD.
Chuck Norris fortunes plugin for Oh My Zsh. Perfectly suitable as MOTD.
**Maintainers**
:
[
apjanke
](
https://github.com/apjanke
)
[
maff
]
(https://github.com/maff)
To use it add
`chucknorris`
to the plugins array in you zshrc file.
To use it add
`chucknorris`
to the plugins array in you zshrc file.
...
...
plugins/chucknorris/chucknorris.plugin.zsh
View file @
53c9661b
# chucknorris: Chuck Norris fortunes
()
{
# %x: name of file containing code being executed
local
fortunes_dir
=
"
${${
(%)
:-
%x
}
:h
}
/fortunes"
# Automatically generate or update Chuck's compiled fortune data file
# Aliases
# $0 must be used outside a local function. This variable name is unlikly to collide.
alias
chuck
=
"fortune -a
$fortunes_dir
"
CHUCKNORRIS_PLUGIN_DIR
=
${
0
:h
}
alias
chuck_cow
=
"chuck | cowthink"
()
{
# Automatically generate or update Chuck's compiled fortune data file
local
DIR
=
$CHUCKNORRIS_PLUGIN_DIR
/fortunes
if
[[
"
$fortunes_dir
/chucknorris"
-ot
"
$fortunes_dir
/chucknorris.dat"
]]
;
then
if
[[
!
-f
$DIR
/chucknorris.dat
]]
||
[[
$DIR
/chucknorris.dat
-ot
$DIR
/chucknorris
]]
;
then
return
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
local
strfile
=
strfile
if
!
which strfile &>/dev/null
&&
[[
-f
/usr/sbin/strfile
]]
;
then
strfile
=
/usr/sbin/strfile
fi
fi
if
which
$strfile
&> /dev/null
;
then
$strfile
$DIR
/chucknorris
$DIR
/chucknorris.dat
>
/dev/null
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
else
local
strfile
=
"
${
commands
[strfile]
:-
/usr/sbin/strfile
}
"
if
[[
!
-x
"
$strfile
"
]]
;
then
echo
"[oh-my-zsh] chucknorris depends on strfile, which is not installed"
>
&2
echo
"[oh-my-zsh] chucknorris depends on strfile, which is not installed"
>
&2
echo
"[oh-my-zsh] strfile is often provided as part of the 'fortune' package"
>
&2
echo
"[oh-my-zsh] strfile is often provided as part of the 'fortune' package"
>
&2
return
fi
fi
fi
# Aliases
# Generate the compiled fortune data file
alias
chuck
=
"fortune -a
$DIR
"
$strfile
"
$fortunes_dir
/chucknorris"
"
$fortunes_dir
/chucknorris.dat"
>
/dev/null
alias
chuck_cow
=
"chuck | cowthink"
}
}
unset
CHUCKNORRIS_PLUGIN_DIR
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