Zsh: Make functions also usable as shell scripts
This commit is contained in:
parent
7cc2df5318
commit
c00f5dce6e
|
@ -1,9 +1,7 @@
|
|||
# -*- mode: shell-script; -*-
|
||||
|
||||
#!/usr/bin/env zsh
|
||||
# Highlight cat output with whatever less is using for highlighting. The command
|
||||
# in $LESSOPEN needs to be able to work with multiple files.
|
||||
function cat-highlight()
|
||||
{
|
||||
|
||||
# Check if we are in a terminal and $LESSOPEN is not empty
|
||||
if [[ -t 1 && -n "${LESSOPEN}" ]]; then
|
||||
local -a args
|
||||
|
@ -22,4 +20,3 @@ function cat-highlight()
|
|||
else
|
||||
\cat "${@}"
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# -*- mode: shell-script; -*-
|
||||
|
||||
#!/usr/bin/env zsh
|
||||
# Export variable to Emacs.
|
||||
function export-emacs
|
||||
{
|
||||
|
||||
if [[ ARGC -eq 0 ]]; then
|
||||
print -u 2 "Usage: ${0} <variable> …"
|
||||
return 1
|
||||
|
@ -15,4 +13,3 @@ function export-emacs
|
|||
value=$(eval print \"\$${name}\")
|
||||
emacsclient -e "(setenv \"${name}\" \"${value}\")" >/dev/null
|
||||
done
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# -*- mode: shell-script; -*-
|
||||
|
||||
#!/usr/bin/env zsh
|
||||
# Get backtrace from gdb
|
||||
function gdb_get_backtrace()
|
||||
{
|
||||
|
||||
if [[ ${ARGC} -ne 2 ]]; then
|
||||
print -u 2 "Usage: ${0} <executable> <core dump>"
|
||||
return 1
|
||||
|
@ -16,4 +14,3 @@ function gdb_get_backtrace()
|
|||
--quiet \
|
||||
-ex "thread apply all bt full" \
|
||||
-ex "quit"
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
# -*- mode: shell-script; -*-
|
||||
|
||||
#!/usr/bin/env zsh
|
||||
# Makes all files in <directory> lower case. Works with Non-ASCII characters.
|
||||
# Equivalent to `zmv "${dir}/(*)" '${dir}/${1:l}'`
|
||||
function mksmol()
|
||||
{
|
||||
|
||||
if [[ ${ARGC} -ne 1 ]]; then
|
||||
print -u 2 "Usage: ${0} <directory>" >&2
|
||||
return 1
|
||||
|
@ -15,4 +13,3 @@ function mksmol()
|
|||
newfile="${dir}/${basename:l}"
|
||||
[[ "${file}" != "${newfile}" ]] && mv "${file}" "${newfile}" || :
|
||||
done
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue