From 7faa2c43403d00c2596d219e3c109a12b44b1489 Mon Sep 17 00:00:00 2001 From: Juni Kim Date: Sat, 28 Jan 2023 09:10:46 -0500 Subject: [PATCH] scripts added --- install_fedora.sh | 2 ++ install_ubuntu.sh | 2 ++ scripts/doc2pdf | 7 +++++++ scripts/gpl | 3 +++ scripts/tmuxs | 27 +++++++++++++++++++++++++++ 5 files changed, 41 insertions(+) create mode 100755 scripts/doc2pdf create mode 100755 scripts/gpl create mode 100755 scripts/tmuxs diff --git a/install_fedora.sh b/install_fedora.sh index 7cc951f..d9cd6d9 100755 --- a/install_fedora.sh +++ b/install_fedora.sh @@ -63,6 +63,8 @@ dotfiles() { fi cp "$DIR/dots/zshrc" "$HOME/.zshrc" cp "$DIR/dots/tmux.conf" "$HOME/.tmux.conf" + mkdir -p "$HOME/.local/bin" || exit 1 + cp -r "$DIR/scripts" "$HOME/.local/bin" || exit 1 } neovim() { diff --git a/install_ubuntu.sh b/install_ubuntu.sh index 70e2094..eb86177 100755 --- a/install_ubuntu.sh +++ b/install_ubuntu.sh @@ -93,6 +93,8 @@ dotfiles() { fi cp "$DIR/dots/zshrc" "$HOME/.zshrc" cp "$DIR/dots/tmux.conf" "$HOME/.tmux.conf" + mkdir -p "$HOME/.local/bin" || exit 1 + cp -r "$DIR/scripts" "$HOME/.local/bin" || exit 1 } neovim() { diff --git a/scripts/doc2pdf b/scripts/doc2pdf new file mode 100755 index 0000000..3a94340 --- /dev/null +++ b/scripts/doc2pdf @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -f "$1" ]; then + libreoffice --headless --convert-to pdf "$1" && rm -rf "$1" +else + echo "$1 is not a file." && exit 1 +fi diff --git a/scripts/gpl b/scripts/gpl new file mode 100755 index 0000000..ae0f0f8 --- /dev/null +++ b/scripts/gpl @@ -0,0 +1,3 @@ +#!/bin/sh + +curl -LJ https://www.gnu.org/licenses/gpl-3.0.md -o LICENSE.md diff --git a/scripts/tmuxs b/scripts/tmuxs new file mode 100755 index 0000000..302d7b3 --- /dev/null +++ b/scripts/tmuxs @@ -0,0 +1,27 @@ +#!/usr/bin/env sh + +WORKSPACES=${WORKSPACES:-$HOME/Documents} + +IFS=':' findargs=$WORKSPACES + +if test -z "$1"; then + sessiondir="$(find $findargs -maxdepth 2 -type d 2>/dev/null | fzf)" +else + sessiondir="$1" +fi + +if test -z "$sessiondir" || ! test -d "$sessiondir"; then + echo "$sessiondir is not a directory. Aborting..." + exit 0 +fi + +name="$(basename "$(realpath "$sessiondir" )" | tr '.' '_')" + +if test -z "$TMUX" && test -z "$(pgrep tmux)"; then + tmux new-session -c "$sessiondir" -s "$name" +else + if ! tmux has-session -t="$name" 2> /dev/null; then + tmux new-session -d -c "$sessiondir" -s "$name" + fi + tmux switch-client -t "$name" +fi