feat: added some more stuff

This commit is contained in:
Raj 2024-07-11 20:09:02 +05:30
parent 52cb2e58e6
commit 309957f291
5 changed files with 107 additions and 0 deletions

14
cheatsheet.sh Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
selected=`cat ~/.tmux-cht-languages ~/.tmux-cht-command | fzf-tmux --reverse -p -h 60% -w 50%`
if [[ -z $selected ]]; then
exit 0
fi
read -p "Enter Query: " query
if grep -qs "$selected" ~/.tmux-cht-languages; then
query=`echo $query | tr ' ' '+'`
tmux neww bash -c "curl -s cht.sh/$selected/$query | less"
else
tmux neww bash -c "curl -s cht.sh/$selected~$query | less"
fi

27
curl-helper.sh Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
method=$(gum choose GET POST PUT PATCH DELETE)
api_url=$(gum input --placeholder="API URL")
header_json="Content-Type: application/json"
case $method in
"POST" | "PUT" | "PATCH")
body=$(gum input --placeholder="Body(JSON)")
query="curl -H \"$header_json\" -d '{ $body }' -X $method $api_url"
;;
"GET" | "DELETE")
query="curl -X $method $api_url"
;;
*)
echo "Invalid method"
exit 1
;;
esac
echo $query
if gum confirm "Do you want to execute the query"; then
eval $query
else
echo "query execution cancelled"
fi

3
install.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/bash
sudo pacman -S ttf-jetbrains-mono-nerd thunar rofi-wayland starship tmux alacritty btop bat fzf lazygit neovim dunst go firefox brightnessctl eza jdk-openjdk maven npm nodejs yay ranger zoxide polybar hyprland slurp grim waybar xdg-desktop-portal-hyprland glow neofetch fastfetch jq tldr

38
rofi-wifi-menu.sh Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env bash
notify-send "Getting list of available Wi-Fi networks..."
# Get a list of available wifi connections and morph it into a nice-looking list
wifi_list=$(nmcli --fields "SECURITY,SSID" device wifi list | sed 1d | sed 's/ */ /g' | sed -E "s/WPA*.?\S/ /g" | sed "s/^--/ /g" | sed "s/ //g" | sed "/--/d")
connected=$(nmcli -fields WIFI g)
if [[ "$connected" =~ "enabled" ]]; then
toggle="󰖪 Disable Wi-Fi"
elif [[ "$connected" =~ "disabled" ]]; then
toggle="󰖩 Enable Wi-Fi"
fi
# Use rofi to select wifi network
chosen_network=$(echo -e "$toggle\n$wifi_list" | uniq -u | rofi -dmenu -i -selected-row 1 -p "Wi-Fi SSID: " )
# Get name of connection
read -r chosen_id <<< "${chosen_network:3}"
if [ "$chosen_network" = "" ]; then
exit
elif [ "$chosen_network" = "󰖩 Enable Wi-Fi" ]; then
nmcli radio wifi on
elif [ "$chosen_network" = "󰖪 Disable Wi-Fi" ]; then
nmcli radio wifi off
else
# Message to show when connection is activated successfully
success_message="You are now connected to the Wi-Fi network \"$chosen_id\"."
# Get saved connections
saved_connections=$(nmcli -g NAME connection)
if [[ $(echo "$saved_connections" | grep -w "$chosen_id") = "$chosen_id" ]]; then
nmcli connection up id "$chosen_id" | grep "successfully" && notify-send "Connection Established" "$success_message"
else
if [[ "$chosen_network" =~ "" ]]; then
wifi_password=$(rofi -dmenu -p "Password: " )
fi
nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && notify-send "Connection Established" "$success_message"
fi
fi

25
tmux-session.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
if [[ $# -eq 1 ]]; then
selected=$1
else
selected=$(fd . ~/.dotfiles/ ~/projects --min-depth 1 --maxdepth 1 --type d --hidden --exclude .git | fzf-tmux -p -h 80% -w 80% --preview="eza {} -L 1 --tree --icons --color=always --git-ignore")
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 -u new-session -s $selected_name -c $selected
exit 0
fi
if ! tmux has-session -t=$selected_name 2> /dev/null; then
tmux -u new-session -ds $selected_name -c $selected
fi
tmux switch-client -t $selected_name