Skip to content

Commit

Permalink
improve remote opener binary (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
ytian81 authored Aug 10, 2024
1 parent d56c54c commit fd382e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
15 changes: 11 additions & 4 deletions bin/open
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/usr/bin/env bash
#!/bin/bash

if [ -p /dev/stdin ]; then
cat - | nc -U "$HOME/.opener.sock"
set -eu

# get data either form stdin or from file
if (( $# == 0 )) ; then
# if no argument, read from standard input from pipe
buf=$(cat "$@")
else
echo "${@}" | nc -U "$HOME/.opener.sock"
# otherwise read from all arguments
buf=$@
fi

echo "$buf" | nc -U "$HOME/.opener.sock"
15 changes: 11 additions & 4 deletions bin/xdg-open
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/usr/bin/env bash
#!/bin/bash

if [ -p /dev/stdin ]; then
cat - | nc -U "$HOME/.opener.sock"
set -eu

# get data either form stdin or from file
if (( $# == 0 )) ; then
# if no argument, read from standard input from pipe
buf=$(cat "$@")
else
echo "${@}" | nc -U "$HOME/.opener.sock"
# otherwise read from all arguments
buf=$@
fi

echo "$buf" | nc -U "$HOME/.opener.sock"

0 comments on commit fd382e6

Please sign in to comment.