From fe8461f4b8dc10cd96d42454bcb667f6e80da090 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Fri, 25 Nov 2022 22:16:50 +0000 Subject: [PATCH] Bring zsh and fish back in sync --- fish/config.fish | 31 +++++++++++++++++++++++++++---- fish/functions/cross.fish | 26 +++++++++++++------------- fish/functions/flgrep.fish | 2 +- fish/functions/power_now.fish | 5 +++++ fish/functions/pw.fish | 14 ++------------ fish/functions/pwnk.fish | 15 +++++++++++++++ fish/functions/pws.fish | 15 ++------------- fish/functions/uart.fish | 13 +++++++++++++ zshrc | 6 +++--- 9 files changed, 81 insertions(+), 46 deletions(-) create mode 100644 fish/functions/power_now.fish create mode 100644 fish/functions/pwnk.fish create mode 100644 fish/functions/uart.fish diff --git a/fish/config.fish b/fish/config.fish index a7ced3b..4ef8e7b 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -26,15 +26,38 @@ set -g fish_color_vcs_braces 29bc7d set -g fish_normal_user js test -n "$XDG_CONFIG_HOME" -or set -x XDG_CONFIG_HOME $HOME/.config +or set -x XDG_CONFIG_HOME "$HOME/.config" test -n "$XDG_CACHE_HOME" -or set -x XDG_CACHE_HOME $HOME/.cache +or set -x XDG_CACHE_HOME "$HOME/.cache" test -n "$XDG_DATA_HOME" -or set -x XDG_DATA_HOME $HOME/.local/share +or set -x XDG_DATA_HOME "$HOME/.local/share" set -x EDITOR vim set -x VIMINIT "source $XDG_CONFIG_HOME/vim/vimrc" set -x LS_COLORS 'di=34:ow=44;37:tw=44;37:st=44;37:ex=31:su=7;31:sg=7;31:ln=33:or=7;33:pi=32:do=32:bd=35:cd=35:so=32:*.bz2=36:*.dmg=36:*.gz=36:*.gpg=36:*.rar=36:*.tar=36:*.tbz2=36:*.tgz=36:*.xz=36:*.zip=36:*.orig=90:*~=90' set -x SUDO_PROMPT (printf "\033[0;31m[\033[1;31msudo -> %%U\033[0;31m]\033[0m Password for \033[1m%%p@%%H\033[0m: ") -set -x GNUPGHOME $XDG_DATA_HOME/gnupg +set -x GNUPGHOME "$XDG_DATA_HOME/gnupg" set -x CVS_RSH ssh + +if type -q gpg + # Make sure the GPG agent is running + gpg --card-status &>/dev/null + + set -l sock + if test -d "$XDG_RUNTIME_DIR/gnupg" + set sock (find $XDG_RUNTIME_DIR/gnupg -name S.gpg-agent.ssh | head -1) + end + if test -z "$sock" + set sock "$GNUPGHOME/S.gpg-agent.ssh" + end + + alias gssh="SSH_AUTH_SOCKET=$sock ssh" + alias gssh-add="SSH_AUTH_SOCKET=$sock ssh-add" + alias gsftp="SSH_AUTH_SOCKET=$sock sftp" +end + +if test (uname -s) = Darwin + set -x MAKEFLAGS -j(math (sysctl -n machdep.cpu.thread_count)'*2') +else if type -q nproc + set -x MAKEFLAGS -j(math (nproc)'*2') +end diff --git a/fish/functions/cross.fish b/fish/functions/cross.fish index d6acc84..acf9abe 100644 --- a/fish/functions/cross.fish +++ b/fish/functions/cross.fish @@ -43,7 +43,7 @@ function cross --description 'Set up cross-compilation environment' return 1 end case ios iossim - if ! type -q xcrun + if not type -q xcrun echo 'Can only cross-compile for iOS on a Mac with Xcode!' return 1 end @@ -66,10 +66,10 @@ function cross --description 'Set up cross-compilation environment' set archs $default_archs end - set -gx CC clang --sysroot $sdk - set -gx CPP clang -E --sysroot $sdk - set -gx CXX clang++ --sysroot $sdk - set -gx CXXPP clang++ -E --sysroot $sdk + set -gx CC clang -isysroot $sdk + set -gx CPP clang -E -isysroot $sdk + set -gx CXX clang++ -isysroot $sdk + set -gx CXXPP clang++ -E -isysroot $sdk for arch in $archs set -a CC -arch $arch @@ -106,7 +106,7 @@ function cross --description 'Set up cross-compilation environment' set PATH $prefix/cross/$cross_host/bin $PATH case morphos - set -l prefix (pkg_info -qp ppc-morphos-gcc-9 | + set -l prefix (pkg_info -qp ppc-morphos-gcc-11 | awk '/^@cwd/ { print $2; exit }') if test -z "$prefix" @@ -115,10 +115,10 @@ function cross --description 'Set up cross-compilation environment' end set PATH $prefix/gg/bin $PATH - set -gx CC ppc-morphos-gcc-9 - set -gx CXX ppc-morphos-g++-9 - set -gx OBJC ppc-morphos-gcc-9 - set -gx OBJCXX ppc-morphos-g++-9 + set -gx CC ppc-morphos-gcc-11 + set -gx CXX ppc-morphos-g++-11 + set -gx OBJC ppc-morphos-gcc-11 + set -gx OBJCXX ppc-morphos-g++-11 set -g cross_host ppc-morphos case switch if test -z "$DEVKITPRO" @@ -130,9 +130,9 @@ function cross --description 'Set up cross-compilation environment' return 1 end - set PATH $DEVKITA64/bin $PATH + set PATH $DEVKITA64/bin $DEVKITPRO/tools/bin $PATH set -g cross_host aarch64-none-elf - set -g objfw_configure_flags --with-switch + set -g objfw_configure_flags --with-nintendo-switch case wii wii-u if test -z "$DEVKITPRO" echo 'Please set DEVKITPRO!' @@ -143,7 +143,7 @@ function cross --description 'Set up cross-compilation environment' return 1 end - set PATH $DEVKITPPC/bin $PATH + set PATH $DEVKITPPC/bin $DEVKITPRO/tools/bin $PATH set -g cross_host powerpc-eabi set -g objfw_configure_flags --with-$argv[1] case '*' diff --git a/fish/functions/flgrep.fish b/fish/functions/flgrep.fish index 4c245a5..16a1cb4 100644 --- a/fish/functions/flgrep.fish +++ b/fish/functions/flgrep.fish @@ -1,6 +1,6 @@ function flgrep set -l ret - fossil changes --all . | sed 's/^.* //' | while read file + fossil changes --all . | awk '{ print $2 }' | while read file grep -H $argv "$file" && set ret 0 test $status -gt 1 && return $status end diff --git a/fish/functions/power_now.fish b/fish/functions/power_now.fish new file mode 100644 index 0000000..bbf80ed --- /dev/null +++ b/fish/functions/power_now.fish @@ -0,0 +1,5 @@ +if test -f /sys/class/power_supply/BAT0/power_now + function power_now + awk '{ print $1*10^-6 " W" }' /sys/class/power_supply/BAT0/power_now + end +end diff --git a/fish/functions/pw.fish b/fish/functions/pw.fish index fbfb5cb..936ca6b 100644 --- a/fish/functions/pw.fish +++ b/fish/functions/pw.fish @@ -1,13 +1,3 @@ -function pw - set -l clipboard - if type -q pbcopy - set clipboard pbcopy - else if type -q xclip - set clipboard xclip - else - echo "No clipboard handler found!" - return 1 - end - - cryptopassphrase -k ~/.cryptopassphrase.key $argv | tr -d '\n' | $clipboard +function pw --wraps pwnk + pwnk -k ~/.cryptopassphrase.key $argv end diff --git a/fish/functions/pwnk.fish b/fish/functions/pwnk.fish new file mode 100644 index 0000000..f8c045f --- /dev/null +++ b/fish/functions/pwnk.fish @@ -0,0 +1,15 @@ +function pwnk + set -l clipboard + if type -q wl-copy + set clipboard wl-copy + else if type -q pbcopy + set clipboard pbcopy + else if type -q xclip + set clipboard xclip + else + echo "No clipboard handler found!" + return 1 + end + + cryptopassphrase $argv | tr -d '\n' | $clipboard +end diff --git a/fish/functions/pws.fish b/fish/functions/pws.fish index 4ef3859..cdff52a 100644 --- a/fish/functions/pws.fish +++ b/fish/functions/pws.fish @@ -1,14 +1,3 @@ -function pws - set -l clipboard - if type -q pbcopy - set clipboard pbcopy - else if type -q xclip - set clipboard xclip - else - echo "No clipboard handler found!" - return 1 - end - - cryptopassphrase -k ~/.cryptopassphrase-server.key $argv \ - | tr -d '\n' | $clipboard +function pw --wraps pwnk + pwnk -k ~/.cryptopassphrase-server.key $argv end diff --git a/fish/functions/uart.fish b/fish/functions/uart.fish new file mode 100644 index 0000000..c711fdb --- /dev/null +++ b/fish/functions/uart.fish @@ -0,0 +1,13 @@ +switch (uname -s) + case Linux + function uart + if not set -q argv[1] + set argv[1] 115200 + end + if not set -q argv[2] + set argv[2] 0 + end + screen /dev/ttyUSB"$argv[2]" "$argv[1]" + end + end +end diff --git a/zshrc b/zshrc index f1e2971..812d830 100644 --- a/zshrc +++ b/zshrc @@ -369,7 +369,7 @@ if __has_command gpg gpg2; then local sock if [ -d "$XDG_RUNTIME_DIR/gnupg" ]; then - sock=$(find $XDG_RUNTIME_DIR/gnupg -name S.gpg-agent.ssh | + sock=$(find "$XDG_RUNTIME_DIR/gnupg" -name S.gpg-agent.ssh | head -1) fi [ -n "$sock" ] || sock="$GNUPGHOME/S.gpg-agent.ssh" @@ -567,12 +567,12 @@ cross() { echo "Please set DEVKITPRO!" return 1 fi - if [ -z $"DEVKITA64" ]; then + if [ -z "$DEVKITA64" ]; then echo "Please set DEVKITA64!" return 1 fi - export PATH="$DEVKITA64/bin:$PATH" + export PATH="$DEVKITA64/bin:$DEVKITPRO/tools/bin:$PATH" export cross_host="aarch64-none-elf" export objfw_configure_flags="--with-$1" ;;