initial commit
This commit is contained in:
commit
46c5b5bcad
2 changed files with 89 additions and 0 deletions
14
README.md
Normal file
14
README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# stic
|
||||
i got sick of manually transferring terminfo files
|
||||
|
||||
# Usage
|
||||
|
||||
```bash
|
||||
stic terminfo-name remote-host [...ssh-args]
|
||||
```
|
||||
|
||||
# Example
|
||||
```bash
|
||||
stic alacritty cute.fox -p 2222
|
||||
```
|
||||
|
75
stic
Executable file
75
stic
Executable file
|
@ -0,0 +1,75 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
usage() {
|
||||
echo "copy terminfo to a remote host because we're sick of this"
|
||||
echo
|
||||
echo "usage: stic [...ssh-args] [-h] term host"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " --help, -h print this message"
|
||||
echo
|
||||
echo "Parameters:"
|
||||
echo " <term> the name of the terminfo to transfer"
|
||||
echo " <host> the remote host address"
|
||||
echo
|
||||
}
|
||||
|
||||
ensure() {
|
||||
if ! $@ ; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# check if any args were passed. if not, display usage information
|
||||
if [ $# == 0 ] ; then
|
||||
usage
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
POSITIONAL_ARGS=()
|
||||
SSH_ARGS=()
|
||||
|
||||
# parse args
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
-*|--*)
|
||||
SSH_ARGS+=("$1")
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
POSITIONAL_ARGS+=("$1") # save positional arg
|
||||
shift # past argument
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameter
|
||||
|
||||
# save the term info
|
||||
TERM="${POSITIONAL_ARGS[0]}"
|
||||
|
||||
# ssh connection string
|
||||
HOST="${POSITIONAL_ARGS[1]}"
|
||||
|
||||
# make a temporary file to output the terminfo
|
||||
TI=`mktemp`
|
||||
|
||||
# store the filename without directory for later
|
||||
FN=$(basename -- "$TI")
|
||||
|
||||
# pass -o LogLevel=error to quiet the output on good connections
|
||||
ARGS="-o LogLevel=error ${SSH_ARGS[*]}"
|
||||
|
||||
# output the terminfo
|
||||
ensure infocmp "$TERM" > "$TI"
|
||||
|
||||
# copy the terminfo to the user's home on the remote machine
|
||||
ensure "scp $ARGS $TI $HOST:"
|
||||
|
||||
# ssh into the machine and install the terminfo with tic
|
||||
sh -c "ssh $ARGS $HOST \"tic -x $FN && rm $FN\""
|
||||
|
Loading…
Reference in a new issue