dotfiles/zsh/functions.zsh

47 lines
700 B
Bash
Raw Normal View History

2018-06-15 13:43:04 +00:00
#!/usr/bin/env zsh
2018-02-23 09:38:24 +00:00
is_linux() {
2018-07-04 20:55:45 +00:00
[[ "$OSTYPE" == linux* ]]
2018-02-23 09:38:24 +00:00
}
is_macos() {
2018-07-04 20:55:45 +00:00
[[ "$OSTYPE" == darwin* ]]
2018-02-23 09:38:24 +00:00
}
2018-08-23 20:46:00 +00:00
is_android() {
[[ "$OSTYPE" == linux-android ]]
}
2018-02-23 09:38:24 +00:00
command_exists() {
2019-08-30 10:13:04 +00:00
command -v "$1" &>/dev/null
2018-02-23 09:38:24 +00:00
}
source_if_exists() {
2018-07-04 20:55:45 +00:00
[[ -f "$1" ]] && source "$1"
2018-02-23 09:38:24 +00:00
}
2018-11-10 20:03:34 +00:00
lazy_load() {
local command="$1"
local init_command="$2"
2019-01-09 16:55:19 +00:00
eval "$command() {
unfunction $command
$init_command
$command \$@
}"
}
2019-03-08 18:10:30 +00:00
welcome() {
python "$ZSH_DOTFILES/welcome/main.py"
2019-03-08 18:10:30 +00:00
}
2019-08-28 07:46:52 +00:00
2019-08-28 07:51:30 +00:00
if is_android; then
alias open='termux-open'
elif is_linux && command_exists xdg-open; then
2019-08-28 07:46:52 +00:00
open() { nohup xdg-open "$@" &> /dev/null; }
fi
2019-09-03 16:57:30 +00:00
set-my-syntax-theme() {
fast-theme "$ZSH_DOTFILES/my-syntax-theme.ini" "$@"
2019-09-03 16:57:30 +00:00
}