diff --git a/bin/x-clip b/bin/x-clip new file mode 100755 index 0000000..e1ba204 --- /dev/null +++ b/bin/x-clip @@ -0,0 +1,33 @@ +#!/bin/sh + +# xsel simulation in WSL +# usage: +# xsel -o +# xsel -i [string] +# From https://www.reddit.com/r/neovim/comments/fyj7mp/neovim_in_wsl_copy_to_windows_clipboard/fn241ig/ + +if command -v pwsh.exe >/dev/null 2>&1; then + pwsh="pwsh.exe" +elif command -v powershell.exe >/dev/null 2>&1; then + pwsh="powershell.exe" +else + exit 1 +fi +pwsh="$pwsh -NoProfile -NoLogo -NonInteractive" + +OUTPUT= +for i in "$@" +do + case "$i" in + -o|--output|-out) + OUTPUT=1 + break + ;; + esac +done + +if [ "$OUTPUT" = "1" ]; then + $pwsh -command 'Get-Clipboard' +else + clip.exe +fi diff --git a/bin/x-open b/bin/x-open index 30dc721..4679043 100755 --- a/bin/x-open +++ b/bin/x-open @@ -1,7 +1,7 @@ #!/bin/sh case $(uname -r) in - *microsoft*) powershell.exe -noprofile start-process "'$@'";; + *microsoft*|*Microsoft*) powershell.exe -noprofile start-process "'$@'";; *) if command -v exo-open >/dev/null 2>&1; then exo-open "$@" 1>/dev/null 2>&1 diff --git a/cli/fish.sh b/cli/fish.sh index 12b8268..fcf7374 100755 --- a/cli/fish.sh +++ b/cli/fish.sh @@ -5,41 +5,49 @@ DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" log 'Setting up shell' -if ! has_cmd fish; then - case "$PM" in - apt) + +case "$PM" in + apt) + if ! has_cmd fish; then sudo add-apt-repository ppa:fish-shell/release-3 -y -n pm_update - sudo apt install fish silversearcher-ag -y - echo DISTRIB_RELEASE_MAJOR: $DISTRIB_RELEASE_MAJOR - echo DISTRIB_RELEASE: $DISTRIB_RELEASE - if [ "$DISTRIB_RELEASE_MAJOR" -gt 19 ] || [ "$DISTRIB_RELEASE" = "19.10" ]; then - sudo apt install dash bat -y - fi - sudo ln -sf /usr/bin/batcat /usr/bin/bat - intorepo https://github.com/junegunn/fzf.git "$HOME/.fzf" - ./install --all - exitrepo - ;; - pacman) - sudo pacman -S --noconfirm --needed fish the_silver_searcher dash bat fzf - # prevent bash upgradation relink /bin/sh - sudo mkdir -p /etc/pacman.d/hooks - echo " - [Trigger] - Type = Package - Operation = Install - Operation = Upgrade - Target = bash + sudo apt install fish + fi + sudo apt install silversearcher-ag -y + echo DISTRIB_RELEASE_MAJOR: $DISTRIB_RELEASE_MAJOR + echo DISTRIB_RELEASE: $DISTRIB_RELEASE + if [ "$DISTRIB_RELEASE_MAJOR" -gt 19 ] || [ "$DISTRIB_RELEASE" = "19.10" ]; then + sudo apt install dash bat -y + fi + sudo ln -sf /usr/bin/batcat /usr/bin/bat + intorepo https://github.com/junegunn/fzf.git "$HOME/.fzf" + ./install --all + exitrepo + ;; + pacman) + sudo pacman -S --noconfirm --needed fish the_silver_searcher dash bat fzf + # prevent bash upgradation relink /bin/sh + sudo mkdir -p /etc/pacman.d/hooks + echo " + [Trigger] + Type = Package + Operation = Install + Operation = Upgrade + Target = bash - [Action] - Description = Re-pointing /bin/sh symlink to dash... - When = PostTransaction - Exec = /usr/bin/ln -sfT dash /usr/bin/sh - Depends = dash - " | sed 's/^ *//' | sudo tee /etc/pacman.d/sh-is-dash.hook >/dev/null - ;; - esac + [Action] + Description = Re-pointing /bin/sh symlink to dash... + When = PostTransaction + Exec = /usr/bin/ln -sfT dash /usr/bin/sh + Depends = dash + " | sed 's/^ *//' | sudo tee /etc/pacman.d/sh-is-dash.hook >/dev/null + ;; +esac + +# xclip/xsel for wsl +if [ -n "$WSL" ]; then + lnsf "$PDIR/bin/x-clip" "$HOME/.local/bin/xsel" + lnsf "$PDIR/bin/x-clip" "$HOME/.local/bin/xclip" fi diff --git a/cli/install.sh b/cli/install.sh index 0f12dd9..6fba559 100755 --- a/cli/install.sh +++ b/cli/install.sh @@ -10,4 +10,4 @@ sudo timedatectl set-ntp on || true . "$DIR/fish.sh" . "$DIR/vim.sh" . "$DIR/tmux.sh" -. "$DIR/ranger.sh" +. "$DIR/nnn.sh" diff --git a/gui/pass.sh b/gui/pass.sh index cd6f43b..25eaec0 100755 --- a/gui/pass.sh +++ b/gui/pass.sh @@ -7,16 +7,17 @@ DIR=$(dirname "$(readlink -f "$0")") if ! has_cmd go; then "$PDIR/devel/go.sh" fi +GNUPG=$HOME/.gnupg +GPG_AGENT_CONF=$GNUPG/gpg-agent.conf +mkdir -p "$GNUPG" # install pass case "$PM" in apt) sudo apt install -y pass - GNUPG=$HOME/.gnupg - GPG_AGENT_CONF=$GNUPG/gpg-agent.conf if [ -n "$WSL" ]; then PINENTRY=$PDIR/bin/pinentry-wsl-ps1.sh - BROWSERPASS_NATIVE= "$(wsl-win-path.sh %USERPROFILE%)/browser-wsl.bat" + BROWSERPASS_NATIVE="$(wsl-win-path.sh %USERPROFILE%)/browser-wsl.bat" echo "@echo off\r\nbash -c 'browserpass'" \ > "$BROWSERPASS_NATIVE" else @@ -24,10 +25,6 @@ case "$PM" in PINENTRY=$(command -v pinentry-gtk-2) fi SETTING="pinentry-program $PINENTRY" - mkdir -p "$GNUPG" - if ! grep -Fq "$SETTING" "$GPG_AGENT_CONF"; then - echo "$SETTING" > GPG_AGENT_CONF - fi ;; pacman) sudo pacman -S --noconfirm --needed \ @@ -38,19 +35,27 @@ esac # longer password caching time cat < ~/.gnupg/gpg-agent.conf +$SETTING default-cache-ttl 28800 max-cache-ttl 28800 EOF -# enable browser-native for google-chrome -make -C /usr/lib/browserpass hosts-chrome-user # install browserpass-native -intorepo https://github.com/browserpass/browserpass-native.git "$DIR/repos/browserpass-native" -make configure -make -sudo make install -exitrepo +if [ -n "$WSL" ]; then + echo "Please download browserpass-native for windows 64 and extract it to /usr/local/bin" + x-open https://github.com/browserpass/browserpass-native/releases/latest +else + intorepo https://github.com/browserpass/browserpass-native.git "$DIR/repos/browserpass-native" + make configure + make + sudo make install + exitrepo +fi + +# enable browser-native for google-chrome +#make -C /usr/lib/browserpass hosts-chrome-user + # chrome extension: https://chrome.google.com/webstore/detail/browserpass/naepdomgkenhinolocfifgehidddafch diff --git a/gui/sysutils.sh b/gui/sysutils.sh index efd6596..1ab2a19 100755 --- a/gui/sysutils.sh +++ b/gui/sysutils.sh @@ -19,7 +19,8 @@ case "$PM" in network-manager network-manager-gnome \ exfat-utils \ dunst \ - xclip xsel xdotool \ + xclip xsel \ + xdotool \ libnotify-bin \ flameshot scrot \ thunar gvfs-bin gvfs-backends thunar-archive-plugin file-roller tumbler