This commit is contained in:
Klesh Wong 2021-10-05 23:29:10 +08:00
parent e479146307
commit 454c34712d
5 changed files with 89 additions and 49 deletions

33
bin/x-clip Executable file
View File

@ -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

View File

@ -5,12 +5,15 @@ DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh"
log 'Setting up shell'
if ! has_cmd fish; then
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
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
@ -40,6 +43,11 @@ if ! has_cmd fish; then
" | 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

View File

@ -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"

View File

@ -7,13 +7,14 @@ 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
sudo apt install -y pass webext-browserpass
if [ -n "$WSL" ]; then
PINENTRY=$PDIR/bin/pinentry-wsl-ps1.sh
BROWSERPASS_NATIVE="$(wsl-win-path.sh %USERPROFILE%)/browser-wsl.bat"
@ -24,33 +25,30 @@ 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 \
go \
browserpass
;;
esac
# longer password caching time
cat <<EOF > ~/.gnupg/gpg-agent.conf
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
;;
esac
# longer password caching time
cat <<EOF > ~/.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
# chrome extension: https://chrome.google.com/webstore/detail/browserpass/naepdomgkenhinolocfifgehidddafch

View File

@ -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