wifi script
This commit is contained in:
parent
7694058b9d
commit
f7d2e0d114
2 changed files with 37 additions and 23 deletions
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
-- Set <space> as the leader key
|
-- Set <space> as the leader key
|
||||||
-- See `:help mapleader`
|
-- See `:help mapleader`
|
||||||
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
|
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
|
||||||
|
@ -76,20 +75,19 @@ vim.opt.scrolloff = 10
|
||||||
-- quickfix to search and replace
|
-- quickfix to search and replace
|
||||||
vim.api.nvim_create_user_command('SearchAndReplace', function()
|
vim.api.nvim_create_user_command('SearchAndReplace', function()
|
||||||
-- Prompt for the first string (the one to replace)
|
-- Prompt for the first string (the one to replace)
|
||||||
local stringOne = vim.fn.input('Enter the string to replace: ')
|
local stringOne = vim.fn.input 'Enter the string to replace: '
|
||||||
-- Prompt for the second string (the replacement)
|
-- Prompt for the second string (the replacement)
|
||||||
local stringTwo = vim.fn.input('Enter the replacement string: ')
|
local stringTwo = vim.fn.input 'Enter the replacement string: '
|
||||||
|
|
||||||
-- Perform the search and replace in the quickfix list
|
-- Perform the search and replace in the quickfix list
|
||||||
vim.cmd('cfdo %s/' .. stringOne .. '/' .. stringTwo .. '/g | update')
|
vim.cmd('cfdo %s/' .. stringOne .. '/' .. stringTwo .. '/g | update')
|
||||||
|
|
||||||
-- Optionally close the buffers
|
-- Optionally close the buffers
|
||||||
vim.cmd('bd')
|
vim.cmd 'bd'
|
||||||
end, {})
|
end, {})
|
||||||
|
|
||||||
-- Map <leader>R to the LadderR command
|
-- Map <leader>R to the LadderR command
|
||||||
vim.api.nvim_set_keymap('n', '<leader>R', ':SearchAndReplace<CR>', { noremap = true, silent = true, desc = 'Search And [R]eplace'})
|
vim.api.nvim_set_keymap('n', '<leader>R', ':SearchAndReplace<CR>', { noremap = true, silent = true, desc = 'Search And [R]eplace' })
|
||||||
|
|
||||||
|
|
||||||
-- [[ Basic Keymaps ]]
|
-- [[ Basic Keymaps ]]
|
||||||
-- See `:help vim.keymap.set()`
|
-- See `:help vim.keymap.set()`
|
||||||
|
@ -574,7 +572,6 @@ require('lazy').setup({
|
||||||
-- You can press `g?` for help in this menu.
|
-- You can press `g?` for help in this menu.
|
||||||
require('mason').setup()
|
require('mason').setup()
|
||||||
|
|
||||||
|
|
||||||
-- You can add other tools here that you want Mason to install
|
-- You can add other tools here that you want Mason to install
|
||||||
-- for you, so that they are available from within Neovim.
|
-- for you, so that they are available from within Neovim.
|
||||||
local ensure_installed = vim.tbl_keys(servers or {})
|
local ensure_installed = vim.tbl_keys(servers or {})
|
||||||
|
@ -636,7 +633,7 @@ require('lazy').setup({
|
||||||
-- python = { "isort", "black" },
|
-- python = { "isort", "black" },
|
||||||
--
|
--
|
||||||
-- You can use 'stop_after_first' to run the first available formatter from the list
|
-- You can use 'stop_after_first' to run the first available formatter from the list
|
||||||
javascript = { "prettier", stop_after_first = true },
|
javascript = { 'prettier', stop_after_first = true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -780,7 +777,6 @@ require('lazy').setup({
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
-- Highlight todo, notes, etc in comments
|
-- Highlight todo, notes, etc in comments
|
||||||
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
|
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,8 @@ forget_network() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to connect to a network
|
||||||
|
|
||||||
# Function to connect to a network
|
# Function to connect to a network
|
||||||
connect_to_network() {
|
connect_to_network() {
|
||||||
while true; do
|
while true; do
|
||||||
|
@ -113,6 +115,21 @@ connect_to_network() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if there's an existing connection profile for this network
|
||||||
|
if nmcli connection show | grep -q "$chosen_network"; then
|
||||||
|
# Try to connect using the saved profile
|
||||||
|
nmcli connection up "$chosen_network"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
# Connection successful
|
||||||
|
notify-send "Connected to $chosen_network using saved profile."
|
||||||
|
break
|
||||||
|
else
|
||||||
|
# If connection fails, delete the saved profile and prompt for a new password
|
||||||
|
nmcli connection delete "$chosen_network"
|
||||||
|
notify-send "Failed to connect with saved password. Enter a new password."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if the network is secured
|
# Check if the network is secured
|
||||||
security_check=$(nmcli -t -f SSID,SECURITY dev wifi | grep "$chosen_network" | awk -F':' '{print $2}')
|
security_check=$(nmcli -t -f SSID,SECURITY dev wifi | grep "$chosen_network" | awk -F':' '{print $2}')
|
||||||
|
|
||||||
|
@ -133,6 +150,7 @@ connect_to_network() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Main menu function
|
# Main menu function
|
||||||
main_menu() {
|
main_menu() {
|
||||||
network_info=$(get_network_info)
|
network_info=$(get_network_info)
|
||||||
|
|
Loading…
Reference in a new issue