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
|
||||
-- See `:help mapleader`
|
||||
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
|
||||
|
@ -76,21 +75,20 @@ vim.opt.scrolloff = 10
|
|||
-- quickfix to search and replace
|
||||
vim.api.nvim_create_user_command('SearchAndReplace', function()
|
||||
-- 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)
|
||||
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
|
||||
vim.cmd('cfdo %s/' .. stringOne .. '/' .. stringTwo .. '/g | update')
|
||||
|
||||
-- Optionally close the buffers
|
||||
vim.cmd('bd')
|
||||
vim.cmd 'bd'
|
||||
end, {})
|
||||
|
||||
-- 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' })
|
||||
|
||||
|
||||
-- [[ Basic Keymaps ]]
|
||||
-- See `:help vim.keymap.set()`
|
||||
|
||||
|
@ -574,7 +572,6 @@ require('lazy').setup({
|
|||
-- You can press `g?` for help in this menu.
|
||||
require('mason').setup()
|
||||
|
||||
|
||||
-- You can add other tools here that you want Mason to install
|
||||
-- for you, so that they are available from within Neovim.
|
||||
local ensure_installed = vim.tbl_keys(servers or {})
|
||||
|
@ -636,7 +633,7 @@ require('lazy').setup({
|
|||
-- python = { "isort", "black" },
|
||||
--
|
||||
-- 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,
|
||||
},
|
||||
|
||||
|
||||
-- Highlight todo, notes, etc in comments
|
||||
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
|
||||
|
||||
|
|
|
@ -78,6 +78,8 @@ forget_network() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Function to connect to a network
|
||||
|
||||
# Function to connect to a network
|
||||
connect_to_network() {
|
||||
while true; do
|
||||
|
@ -113,6 +115,21 @@ connect_to_network() {
|
|||
exit 1
|
||||
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
|
||||
security_check=$(nmcli -t -f SSID,SECURITY dev wifi | grep "$chosen_network" | awk -F':' '{print $2}')
|
||||
|
||||
|
@ -133,6 +150,7 @@ connect_to_network() {
|
|||
done
|
||||
}
|
||||
|
||||
|
||||
# Main menu function
|
||||
main_menu() {
|
||||
network_info=$(get_network_info)
|
||||
|
|
Loading…
Reference in a new issue