From cc00374c883ecf054b84a481eb0d78f54fd8eb8a Mon Sep 17 00:00:00 2001 From: hedy Date: Fri, 13 Jan 2023 17:13:11 +0800 Subject: [PATCH] Fixes for MacOS --- .startup.sh | 18 ++++++++++++++++-- dotscripts/gen/fish-exportenvs | 21 +++++++++++---------- dotscripts/setup/nvim | 4 ++-- iswsl.vim | 2 +- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.startup.sh b/.startup.sh index 86eddac..33fc6ba 100644 --- a/.startup.sh +++ b/.startup.sh @@ -5,8 +5,22 @@ # For fish see ~/dotscripts/setup/fish and ~/.config/fish/config.fish # Determine current running shell. -# unix.stackexchange.com/questions/71121/ (comment by frostschutz) -CURSHELL="$(sed -re 's/\x0.*//' /proc/$$/cmdline)" +# https://unix.stackexchange.com/a/72475 +if test -n "$ZSH_VERSION"; then + CURSHELL=zsh +elif test -n "$FISH_VERSION"; then + CURSHELL=fish +elif test -n "$BASH_VERSION"; then + CURSHELL=bash +elif test -n "$KSH_VERSION"; then + CURSHELL=ksh +elif test -n "$FCEDIT"; then + CURSHELL=ksh +elif test -n "$PS3"; then + CURSHELL=unknown +else + CURSHELL=sh +fi # Add the paths export PATH="$(~/bin/parse_addpath | sed 's/ /:/g'):$PATH" diff --git a/dotscripts/gen/fish-exportenvs b/dotscripts/gen/fish-exportenvs index b9f337f..aa0e290 100755 --- a/dotscripts/gen/fish-exportenvs +++ b/dotscripts/gen/fish-exportenvs @@ -1,18 +1,19 @@ -#!/usr/bin/env fish +#!/usr/bin/env bash + +# TODO: Use aerc instead # Stubbornly translates ~/.exportenvs to ~/.exportenvs.fish echo "" > ~/.exportenvs.fish # clear the file -for fileline in (cat ~/.exportenvs | sed 's/#!.\+$/#!\/usr\/bin\/env fish/') - set line (echo "$fileline" | sed 's/export //' | sed 's/#.\+//') - if test -z "$line" +while read fileline; do + line=$(echo "$fileline" | sed 's/#. sed 's/export //' | sed 's/#\.\+//') + if [ -z "$line" ]; then echo "Adding '$fileline' as-is" echo "$fileline" >> ~/.exportenvs.fish continue - end - set name (echo "$line" | sed 's/=.\+$//' | sed 's/^$//') - set content (echo "$line" | sed 's/^.\+=//' | sed 's/\$(/(/') - echo "Adding $name with $content" - echo set -x "$name" $content >> ~/.exportenvs.fish -end + fi + tline=$(echo "$line" | sed 's/=/ /') + echo Adding "$tline" + echo "set -x $tline" >> ~/.exportenvs.fish +done < ~/.exportenvs diff --git a/dotscripts/setup/nvim b/dotscripts/setup/nvim index cb39941..4ec1b23 100755 --- a/dotscripts/setup/nvim +++ b/dotscripts/setup/nvim @@ -9,8 +9,8 @@ DEST=${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim" if ! [[ -f "$DEST" ]]; then echo "installing vim-plug for nvim" - sh -c 'curl -fLo "$DEST" --create-dirs \ - https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + curl -fLo "$DEST" --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim echo "installing nvim plugins" nvim +PlugInstall +qall else diff --git a/iswsl.vim b/iswsl.vim index e3d4411..22c44ce 100644 --- a/iswsl.vim +++ b/iswsl.vim @@ -1,5 +1,5 @@ function! IsWSL() - if has("unix") + if has("unix") && !has("mac") let lines = readfile("/proc/version") if lines[0] =~ "Microsoft" return 1