added some tmux scripts and misc
This commit is contained in:
parent
fde1d71bf8
commit
184d51a65c
19
scripts/cht.sh
Executable file
19
scripts/cht.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
commands="find man tldr sed awk tr cp ls grep xargs rg ps mv kill lsof less head tail tar cp rm rename jq cat ssh cargo git git-worktree git-status git-commit git-rebase docker docker-compose stow chmod chown make"
|
||||
|
||||
languages="golang solidity vlang v nodejs javascript tmux typescript zsh cpp c lua rust python bash php haskell ArnoldC css html gdb"
|
||||
|
||||
selected=$(echo "$commands $languages" | tr ' ' '\n' | fzf)
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read -p "Enter Query: " query
|
||||
|
||||
if grep -qs "$selected" "$languages"; then
|
||||
query=$(echo "$query" | tr ' ' '+')
|
||||
tmux neww bash -c "curl cht.sh/$selected/$query & while [ : ]; do sleep 1; done"
|
||||
else
|
||||
tmux neww bash -c "curl -s cht.sh/$selected~$query | less"
|
||||
fi
|
||||
16
scripts/screenlayout
Executable file
16
scripts/screenlayout
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
layouts=($(ls "$HOME/.screenlayout/"))
|
||||
|
||||
add="add layout..."
|
||||
|
||||
layouts+=("$add")
|
||||
|
||||
choice=$( printf '%s\n' "${layouts[@]}" | dmenu -i -p 'Choose a screenlayout:') "$@" || exit
|
||||
|
||||
if [ "$choice" = "$add" ]
|
||||
then
|
||||
arandr &
|
||||
else
|
||||
exec "$HOME/.screenlayout/$choice"
|
||||
fi
|
||||
10
scripts/switchkb
Executable file
10
scripts/switchkb
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
##
|
||||
# Switches to the given keyboard (argument) and sets
|
||||
# xmodmap to $2 so that everything works as expected.
|
||||
##
|
||||
|
||||
setxkbmap "$1"
|
||||
|
||||
xmodmap -pke "$2" > /dev/null 2>&1
|
||||
28
scripts/tmux-sessioniser
Executable file
28
scripts/tmux-sessioniser
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Simple tool that can be run to create a tmux session or
|
||||
# connect to an existing one.
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected=$1
|
||||
else
|
||||
selected=$(find ~/repos ~/.config ~/ ~/work ~/.xmonad ~/nextcloud -mindepth 1 -maxdepth 1 -type d | fzf)
|
||||
fi
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
selected_name=$(basename "$selected" | tr . _)
|
||||
tmux_running=$(pgrep tmux)
|
||||
|
||||
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
||||
tmux new-session -s "$selected_name" -c "$selected"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! tmux has-session -t="$selected_name" 2> /dev/null; then
|
||||
tmux new-session -ds "$selected_name" -c "$selected"
|
||||
fi
|
||||
|
||||
tmux switch-client -t "$selected_name"
|
||||
15
scripts/tmux-worker
Executable file
15
scripts/tmux-worker
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
session="system"
|
||||
|
||||
# Check if the session exists, discarding output
|
||||
# We can check $? for the exit status (zero for success, non-zero for failure)
|
||||
tmux has-session -t $session 2>/dev/null
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
# Set up your session
|
||||
tmux new-session -s "$session"
|
||||
fi
|
||||
|
||||
# Attach to created session
|
||||
tmux attach-session -t "$session"
|
||||
Reference in New Issue
Block a user