From 309957f29126711936e0af9759f74ef324d5a3d7 Mon Sep 17 00:00:00 2001 From: Raj Sharma Date: Thu, 11 Jul 2024 20:09:02 +0530 Subject: [PATCH] feat: added some more stuff --- cheatsheet.sh | 14 ++++++++++++++ curl-helper.sh | 27 +++++++++++++++++++++++++++ install.sh | 3 +++ rofi-wifi-menu.sh | 38 ++++++++++++++++++++++++++++++++++++++ tmux-session.sh | 25 +++++++++++++++++++++++++ 5 files changed, 107 insertions(+) create mode 100755 cheatsheet.sh create mode 100755 curl-helper.sh create mode 100755 install.sh create mode 100755 rofi-wifi-menu.sh create mode 100755 tmux-session.sh diff --git a/cheatsheet.sh b/cheatsheet.sh new file mode 100755 index 0000000..4f6f06c --- /dev/null +++ b/cheatsheet.sh @@ -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 diff --git a/curl-helper.sh b/curl-helper.sh new file mode 100755 index 0000000..3a8d173 --- /dev/null +++ b/curl-helper.sh @@ -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 diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..efd4486 --- /dev/null +++ b/install.sh @@ -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 diff --git a/rofi-wifi-menu.sh b/rofi-wifi-menu.sh new file mode 100755 index 0000000..fb45671 --- /dev/null +++ b/rofi-wifi-menu.sh @@ -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 diff --git a/tmux-session.sh b/tmux-session.sh new file mode 100755 index 0000000..1e0237a --- /dev/null +++ b/tmux-session.sh @@ -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