mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[zsh] refactor platform identification
This commit is contained in:
parent
894a81f2b3
commit
e549d7fa2f
3 changed files with 17 additions and 8 deletions
|
@ -16,10 +16,6 @@ viscd() {
|
||||||
rm -f -- "$temp_file"
|
rm -f -- "$temp_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
is_linux() { [[ "$OSTYPE" == linux* ]]; }
|
|
||||||
is_macos() { [[ "$OSTYPE" == darwin* ]]; }
|
|
||||||
is_android() { [[ "$OSTYPE" == linux-android ]]; }
|
|
||||||
|
|
||||||
command_exists() { command -v "$1" &>/dev/null; }
|
command_exists() { command -v "$1" &>/dev/null; }
|
||||||
|
|
||||||
lazy_load() {
|
lazy_load() {
|
||||||
|
@ -33,8 +29,8 @@ lazy_load() {
|
||||||
}"
|
}"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! is_macos; then
|
if (( ! _is_macos )); then
|
||||||
if is_android; then
|
if (( _is_android )); then
|
||||||
open_cmd='termux-open'
|
open_cmd='termux-open'
|
||||||
elif command_exists xdg-open; then
|
elif command_exists xdg-open; then
|
||||||
open_cmd='nohup xdg-open &> /dev/null'
|
open_cmd='nohup xdg-open &> /dev/null'
|
||||||
|
@ -45,7 +41,7 @@ if ! is_macos; then
|
||||||
unset open_cmd
|
unset open_cmd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_macos; then
|
if (( _is_macos )); then
|
||||||
copy_cmd='pbcopy' paste_cmd='pbpaste'
|
copy_cmd='pbcopy' paste_cmd='pbpaste'
|
||||||
elif command_exists xclip; then
|
elif command_exists xclip; then
|
||||||
copy_cmd='xclip -in -selection clipboard' paste_cmd='xclip -out -selection clipboard'
|
copy_cmd='xclip -in -selection clipboard' paste_cmd='xclip -out -selection clipboard'
|
||||||
|
|
|
@ -17,7 +17,7 @@ path_prepend() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_macos; then
|
if (( _is_macos )); then
|
||||||
# local Python binaries (for some reason they don't go into ~/.local/bin, but
|
# local Python binaries (for some reason they don't go into ~/.local/bin, but
|
||||||
# instead into the garbage ~/Library directory)
|
# instead into the garbage ~/Library directory)
|
||||||
path_prepend path ~/Library/Python/*/bin(OnN)
|
path_prepend path ~/Library/Python/*/bin(OnN)
|
||||||
|
|
13
zsh/zshrc
13
zsh/zshrc
|
@ -33,6 +33,19 @@ autoload -U colors && colors
|
||||||
|
|
||||||
_perf_timer_start "total"
|
_perf_timer_start "total"
|
||||||
|
|
||||||
|
# platform identification {{{
|
||||||
|
if [[ "$OSTYPE" == linux* ]]; then
|
||||||
|
_is_linux=1
|
||||||
|
if [[ "$OSTYPE" == linux-android ]]; then
|
||||||
|
_is_android=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$OSTYPE" == darwin* ]]; then
|
||||||
|
_is_macos=1
|
||||||
|
fi
|
||||||
|
# }}}
|
||||||
|
|
||||||
for script in functions options path env plugins aliases completion zle prompt colorscheme; do
|
for script in functions options path env plugins aliases completion zle prompt colorscheme; do
|
||||||
_perf_timer_start "$script.zsh"
|
_perf_timer_start "$script.zsh"
|
||||||
source "$ZSH_DOTFILES/$script.zsh"
|
source "$ZSH_DOTFILES/$script.zsh"
|
||||||
|
|
Loading…
Reference in a new issue