summaryrefslogtreecommitdiff
path: root/mac/.local/bin
diff options
context:
space:
mode:
Diffstat (limited to 'mac/.local/bin')
-rwxr-xr-xmac/.local/bin/gitupdate5
-rwxr-xr-xmac/.local/bin/ifinstalled7
-rwxr-xr-xmac/.local/bin/lfub2
-rwxr-xr-xmac/.local/bin/localshortcuts (renamed from mac/.local/bin/shortcuts)56
-rwxr-xr-xmac/.local/bin/rgafiles6
-rwxr-xr-xmac/.local/bin/tmuxdbussync26
-rwxr-xr-xmac/.local/bin/torwrap2
-rwxr-xr-xmac/.local/bin/transadd5
8 files changed, 57 insertions, 52 deletions
diff --git a/mac/.local/bin/gitupdate b/mac/.local/bin/gitupdate
index 4fed27e..a2c83b5 100755
--- a/mac/.local/bin/gitupdate
+++ b/mac/.local/bin/gitupdate
@@ -2,7 +2,10 @@
set -eu
-pidof transmission-daemon >/dev/null && echo "Turn off transmission-daemon first!" && exit 1
+pgrep -x transmission-daemon >/dev/null 2>&1 && {
+ echo "Turn off transmission-daemon first!"
+ exit 1
+}
# Check if inside a Git repository
! git rev-parse --is-inside-work-tree >/dev/null 2>&1 && echo "Not a git repository." && exit 1
diff --git a/mac/.local/bin/ifinstalled b/mac/.local/bin/ifinstalled
index d0bd26b..b48dd63 100755
--- a/mac/.local/bin/ifinstalled
+++ b/mac/.local/bin/ifinstalled
@@ -6,7 +6,10 @@
# various other scripts for clarity's sake.
for x in "$@"; do
- if ! which "$x" >/dev/null 2>&1 && ! pacman -Qq "$x" >/dev/null 2>&1; then
- notify-send "📦 $x" "must be installed for this function." && exit 1
+ if ! command -v "$x" >/dev/null 2>&1 &&
+ ! brew list --formula "$x" >/dev/null 2>&1 &&
+ ! brew list --cask "$x" >/dev/null 2>&1; then
+ osascript -e 'display notification "'"$x"' must be installed for this function." with title "📦 Dependency missing"'
+ exit 1
fi
done
diff --git a/mac/.local/bin/lfub b/mac/.local/bin/lfub
index c999412..065f7c7 100755
--- a/mac/.local/bin/lfub
+++ b/mac/.local/bin/lfub
@@ -19,6 +19,6 @@ else
mkfifo "$FIFO_UEBERZUGPP"
ueberzugpp layer -s -p json <"$FIFO_UEBERZUGPP" &
exec 3>"$FIFO_UEBERZUGPP"
- trap cleanup HUP INT QUIT TERM PWR EXIT
+ trap cleanup HUP INT QUIT TERM EXIT
lf "$@" 3>&-
fi
diff --git a/mac/.local/bin/shortcuts b/mac/.local/bin/localshortcuts
index 118becb..b9d5ba9 100755
--- a/mac/.local/bin/shortcuts
+++ b/mac/.local/bin/localshortcuts
@@ -24,7 +24,7 @@ printf "\" vim: filetype=vim\\n" >"$vifm_shortcuts"
# Format the `directories` file in the correct syntax and sent it to all three configs.
eval "echo \"$(cat "$bmdirs")\"" |
- awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
+ gawk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
printf(\"%s=\42cd %s && ls -A\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" ;
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
@@ -41,7 +41,7 @@ eval "echo \"$(cat "$bmdirs")\"" |
# Format the `files` file in the correct syntax and sent it to both configs.
eval "echo \"$(cat "$bmfiles")\"" |
- awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
+ gawk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" ;
printf(\"v%s=\42\$EDITOR2 %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
@@ -58,29 +58,29 @@ eval "echo \"$(cat "$bmfiles")\"" |
printf(\"vim.keymap.set('c', ';%s', '%s<cr>', { noremap = true, silent = true, desc = '%s' })\n\", \$1, \$2, gensub(\"^/home/$USER/\",\"~/\",\"g\",\$2)) >> \"$nvim_shortcuts\" ;
printf(\"vim.keymap.set('n', '<localleader><localleader>%s', '<cmd>e %s<cr>', { noremap = true, silent = true, desc = '%s' })\n\", \$1, \$2, gensub(\"^/home/$USER/\",\"~/\",\"g\",\$2)) >> \"$nvim_shortcuts\"}"
-# root
-root_shell_shortcuts="/root/.config/shell/rootshortcutrc"
-root_zsh_named_dirs="/root/.config/shell/rootzshnameddirrc"
-root_lf_shortcuts="/root/.config/lf/rootshortcutrc"
-root_vim_shortcuts="/root/.config/vim/rootshortcuts.vim"
-
-sudo rm -f "$root_zsh_named_dirs" "$root_lf_shortcuts" "$root_vim_shortcuts" 2>/dev/null
-printf "# vim: filetype=sh\\nalias " | sudo tee "$root_shell_shortcuts" 2>/dev/null
-sudo mkdir -p /root/.config/shell/ /root/.config/lf/ /root/.config/vim/
-sudo touch "$root_shell_shortcuts" "$root_zsh_named_dirs" "$root_lf_shortcuts" "$root_vim_shortcuts"
-
-eval "echo \"$(cat "$bmdirs")\"" |
- sudo awk "!/^\s*#/ && !/^\s*\$/ && /cache|config($|\/bash|\/lf|\/shell|\/vim)|local\/(bin|share|state)$/ {gsub(\"\\\s*#.*$\",\"\"); gsub(\"home/$USER\", \"root\");
- printf(\",%s=\42cd %s && ls -A\42 \\\\\n\",\$1,\$2) >> \"$root_shell_shortcuts\" ;
- printf(\"hash -d ,%s=%s \n\",\$1,\$2) >> \"$root_zsh_named_dirs\" ;
- printf(\"map ,%s cd \42%s\42 \n\",\$1,\$2) >> \"$root_lf_shortcuts\" ;
- printf(\"cmap ;%s %s\n\",\$1,\$2) >> \"$root_vim_shortcuts\" ;
- printf(\"nmap <localleader><localleader>%s :Explore %s<cr>\n\",\$1,\$2) >> \"$root_vim_shortcuts\"}"
-
-eval "echo \"$(cat "$bmfiles")\"" |
- sudo awk "!/^\s*#/ && !/^\s*\$/ && /config\/(bash|lf|vim)\/.*rc |inputrc|\$EDITOR / {gsub(\"\\\s*#.*$\",\"\"); gsub(\"home/$USER\", \"root\");
- printf(\",%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$root_shell_shortcuts\" ;
- printf(\"hash -d ,%s=%s \n\",\$1,\$2) >> \"$root_zsh_named_dirs\" ;
- printf(\"map ,%s \$\$EDITOR \42%s\42 \n\",\$1,\$2) >> \"$root_lf_shortcuts\" ;
- printf(\"cmap ;%s %s\n\",\$1,\$2) >> \"$root_vim_shortcuts\" ;
- printf(\"nmap <localleader><localleader>%s :e %s<cr>\n\",\$1,\$2) >> \"$root_vim_shortcuts\"}"
+# # root
+# root_shell_shortcuts="/root/.config/shell/rootshortcutrc"
+# root_zsh_named_dirs="/root/.config/shell/rootzshnameddirrc"
+# root_lf_shortcuts="/root/.config/lf/rootshortcutrc"
+# root_vim_shortcuts="/root/.config/vim/rootshortcuts.vim"
+#
+# sudo rm -f "$root_zsh_named_dirs" "$root_lf_shortcuts" "$root_vim_shortcuts" 2>/dev/null
+# printf "# vim: filetype=sh\\nalias " | sudo tee "$root_shell_shortcuts" 2>/dev/null
+# sudo mkdir -p /root/.config/shell/ /root/.config/lf/ /root/.config/vim/
+# sudo touch "$root_shell_shortcuts" "$root_zsh_named_dirs" "$root_lf_shortcuts" "$root_vim_shortcuts"
+#
+# eval "echo \"$(cat "$bmdirs")\"" |
+# sudo awk "!/^\s*#/ && !/^\s*\$/ && /cache|config($|\/bash|\/lf|\/shell|\/vim)|local\/(bin|share|state)$/ {gsub(\"\\\s*#.*$\",\"\"); gsub(\"home/$USER\", \"root\");
+# printf(\",%s=\42cd %s && ls -A\42 \\\\\n\",\$1,\$2) >> \"$root_shell_shortcuts\" ;
+# printf(\"hash -d ,%s=%s \n\",\$1,\$2) >> \"$root_zsh_named_dirs\" ;
+# printf(\"map ,%s cd \42%s\42 \n\",\$1,\$2) >> \"$root_lf_shortcuts\" ;
+# printf(\"cmap ;%s %s\n\",\$1,\$2) >> \"$root_vim_shortcuts\" ;
+# printf(\"nmap <localleader><localleader>%s :Explore %s<cr>\n\",\$1,\$2) >> \"$root_vim_shortcuts\"}"
+#
+# eval "echo \"$(cat "$bmfiles")\"" |
+# sudo awk "!/^\s*#/ && !/^\s*\$/ && /config\/(bash|lf|vim)\/.*rc |inputrc|\$EDITOR / {gsub(\"\\\s*#.*$\",\"\"); gsub(\"home/$USER\", \"root\");
+# printf(\",%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$root_shell_shortcuts\" ;
+# printf(\"hash -d ,%s=%s \n\",\$1,\$2) >> \"$root_zsh_named_dirs\" ;
+# printf(\"map ,%s \$\$EDITOR \42%s\42 \n\",\$1,\$2) >> \"$root_lf_shortcuts\" ;
+# printf(\"cmap ;%s %s\n\",\$1,\$2) >> \"$root_vim_shortcuts\" ;
+# printf(\"nmap <localleader><localleader>%s :e %s<cr>\n\",\$1,\$2) >> \"$root_vim_shortcuts\"}"
diff --git a/mac/.local/bin/rgafiles b/mac/.local/bin/rgafiles
index e8b5e72..ea02fc9 100755
--- a/mac/.local/bin/rgafiles
+++ b/mac/.local/bin/rgafiles
@@ -29,10 +29,6 @@ search_term() {
echo "Error: 'rga' is not installed." >&2
exit 1
fi
- if ! command -v xclip >/dev/null 2>&1; then
- echo "Error: 'xclip' is not installed." >&2
- exit 1
- fi
# Construct the preview command
preview_cmd=$(printf "rga %s --pretty --context 10 '%s' {}" "$case_flag" "$*")
@@ -48,7 +44,7 @@ search_term() {
fi
# copy target to the clipboard
- echo "$@" | xclip -selection clipboard 2>/dev/null
+ echo "$@" | pbcopy 2>/dev/null
openfiles "$files"
diff --git a/mac/.local/bin/tmuxdbussync b/mac/.local/bin/tmuxdbussync
index d6da872..b049fae 100755
--- a/mac/.local/bin/tmuxdbussync
+++ b/mac/.local/bin/tmuxdbussync
@@ -1,15 +1,15 @@
#!/bin/sh
-fcitx5_pid=$(pgrep -f fcitx5 | head -n1)
-
-if [ -z "$fcitx5_pid" ]; then
- echo "echo 'No terminal process found matching: fcitx5' >&2"
- exit 1
-fi
-
-fcitx5_dbus=$(tr '\0' '\n' </proc/"$fcitx5_pid"/environ | grep DBUS_SESSION_BUS_ADDRESS)
-fcitx5_dbus="${fcitx5_dbus#DBUS_SESSION_BUS_ADDRESS=}"
-
-if [ "$DBUS_SESSION_BUS_ADDRESS" != "$fcitx5_dbus" ]; then
- echo "export DBUS_SESSION_BUS_ADDRESS=$fcitx5_dbus"
-fi
+# fcitx5_pid=$(pgrep -f fcitx5 | head -n1)
+#
+# if [ -z "$fcitx5_pid" ]; then
+# echo "echo 'No terminal process found matching: fcitx5' >&2"
+# exit 1
+# fi
+#
+# fcitx5_dbus=$(tr '\0' '\n' </proc/"$fcitx5_pid"/environ | grep DBUS_SESSION_BUS_ADDRESS)
+# fcitx5_dbus="${fcitx5_dbus#DBUS_SESSION_BUS_ADDRESS=}"
+#
+# if [ "$DBUS_SESSION_BUS_ADDRESS" != "$fcitx5_dbus" ]; then
+# echo "export DBUS_SESSION_BUS_ADDRESS=$fcitx5_dbus"
+# fi
diff --git a/mac/.local/bin/torwrap b/mac/.local/bin/torwrap
index 54f5c0e..f038361 100755
--- a/mac/.local/bin/torwrap
+++ b/mac/.local/bin/torwrap
@@ -2,7 +2,7 @@
ifinstalled stig transmission-cli || exit 1
-! pidof transmission-daemon >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..."
+! pgrep -x transmission-daemon >/dev/null 2>&1 && transmission-daemon && osascript -e 'display notification "Starting torrent daemon..." with title "transmission-daemon"'
"${TERMINAL:-st}" -n stig -e stig
pkill -RTMIN+22 "${STATUSBAR:-dwmblocks}"
diff --git a/mac/.local/bin/transadd b/mac/.local/bin/transadd
index ffd8ded..c6d2e94 100755
--- a/mac/.local/bin/transadd
+++ b/mac/.local/bin/transadd
@@ -4,7 +4,10 @@
# transmission-daemon sometimes fails to take remote requests in its first moments, hence the sleep.
-pidof transmission-daemon >/dev/null || (transmission-daemon && notify-send "💡 Starting transmission daemon..." && sleep 3 && pkill -RTMIN+22 "${STATUSBAR:-dwmblocks}")
+pgrep -x transmission-daemon >/dev/null 2>&1 || (
+ transmission-daemon &&
+ osascript -e 'display notification "💡 Starting transmission daemon..." with title "transmission-daemon"'
+)
directory="$HOME/Torrents"