mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 05:12:27 +00:00
Compare commits
11 Commits
68cb0c7b15
...
047ee12664
Author | SHA1 | Date | |
---|---|---|---|
|
047ee12664 | ||
|
e3688e9b3d | ||
|
51631a16cb | ||
|
d39ffad527 | ||
|
c0982a787f | ||
|
4f7de594a6 | ||
|
fa2f838b63 | ||
|
f688f0c9dd | ||
|
9618128ff8 | ||
|
858d1194fb | ||
|
96af3c9b6e |
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
|
@ -16,6 +16,7 @@ cd linutil
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. Make your changes
|
## 3. Make your changes
|
||||||
|
|
||||||
- **Edit the files you want to change**: Make your changes to the relevant files.
|
- **Edit the files you want to change**: Make your changes to the relevant files.
|
||||||
- **Test your changes**: Run `cargo run` to test your modifications in a local environment and ensure everything works as expected.
|
- **Test your changes**: Run `cargo run` to test your modifications in a local environment and ensure everything works as expected.
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@ cd linutil
|
||||||
## 11. Documentation
|
## 11. Documentation
|
||||||
|
|
||||||
- **Update the documentation**: If your change affects the functionality, please update the relevant documentation files to reflect this.
|
- **Update the documentation**: If your change affects the functionality, please update the relevant documentation files to reflect this.
|
||||||
|
- **Automatic generation**: If you decide to add functionality through a new shell script, make sure to fill out all fields in `tab_data.toml` and run `cargo xtask docgen`.
|
||||||
|
|
||||||
## 12. License
|
## 12. License
|
||||||
|
|
||||||
|
|
2
.github/workflows/github-pages.yml
vendored
2
.github/workflows/github-pages.yml
vendored
|
@ -22,7 +22,7 @@ jobs:
|
||||||
|
|
||||||
- name: Copy Contributing Guidelines
|
- name: Copy Contributing Guidelines
|
||||||
run: |
|
run: |
|
||||||
echo "<!-- THIS FILE IS GENERATED AUTOMATICALLY. EDIT .github/CONTRIBUTING.md -->\n\n$(cat .github/CONTRIBUTING.md)" > 'docs/contributing.md'
|
echo -e "<!-- THIS FILE IS GENERATED AUTOMATICALLY. EDIT .github/CONTRIBUTING.md -->\n\n$(cat .github/CONTRIBUTING.md)" > 'docs/contributing.md'
|
||||||
|
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v5
|
- uses: stefanzweifel/git-auto-commit-action@v5
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -129,17 +129,17 @@ picom_animations() {
|
||||||
|
|
||||||
clone_config_folders() {
|
clone_config_folders() {
|
||||||
# Ensure the target directory exists
|
# Ensure the target directory exists
|
||||||
[ ! -d ~/.config ] && mkdir -p ~/.config
|
[ ! -d "$HOME/.config" ] && mkdir -p "$HOME/.config"
|
||||||
|
|
||||||
# Iterate over all directories in config/*
|
# Iterate over all directories in config/*
|
||||||
for dir in config/*/; do
|
for dir in config/*/; do
|
||||||
# Extract the directory name
|
# Extract the directory name
|
||||||
dir_name=$(basename "$dir")
|
dir_name=$(basename "$dir")
|
||||||
|
|
||||||
# Clone the directory to ~/.config/
|
# Clone the directory to $HOME/.config/
|
||||||
if [ -d "$dir" ]; then
|
if [ -d "$dir" ]; then
|
||||||
cp -r "$dir" ~/.config/
|
cp -r "$dir" "$HOME/.config/"
|
||||||
printf "%b\n" "${GREEN}Cloned $dir_name to ~/.config/${RC}"
|
printf "%b\n" "${GREEN}Cloned $dir_name to $HOME/.config/${RC}"
|
||||||
else
|
else
|
||||||
printf "%b\n" "${RED}Directory $dir_name does not exist, skipping${RC}"
|
printf "%b\n" "${RED}Directory $dir_name does not exist, skipping${RC}"
|
||||||
fi
|
fi
|
||||||
|
@ -153,11 +153,11 @@ configure_backgrounds() {
|
||||||
# Set the variable BG_DIR to the path where backgrounds will be stored
|
# Set the variable BG_DIR to the path where backgrounds will be stored
|
||||||
BG_DIR="$PIC_DIR/backgrounds"
|
BG_DIR="$PIC_DIR/backgrounds"
|
||||||
|
|
||||||
# Check if the ~/Pictures directory exists
|
# Check if the $HOME/Pictures directory exists
|
||||||
if [ ! -d "$PIC_DIR" ]; then
|
if [ ! -d "$PIC_DIR" ]; then
|
||||||
# If it doesn't exist, print an error message and return with a status of 1 (indicating failure)
|
# If it doesn't exist, print an error message and return with a status of 1 (indicating failure)
|
||||||
printf "%b\n" "${RED}Pictures directory does not exist${RC}"
|
printf "%b\n" "${RED}Pictures directory does not exist${RC}"
|
||||||
mkdir ~/Pictures
|
mkdir "$HOME/Pictures"
|
||||||
printf "%b\n" "${GREEN}Directory was created in Home folder${RC}"
|
printf "%b\n" "${GREEN}Directory was created in Home folder${RC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,10 @@ installLinutil() {
|
||||||
printf "%b\n" "${YELLOW}Installing rustup...${RC}"
|
printf "%b\n" "${YELLOW}Installing rustup...${RC}"
|
||||||
case "$PACKAGER" in
|
case "$PACKAGER" in
|
||||||
pacman)
|
pacman)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup
|
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm curl rustup man-db
|
||||||
;;
|
;;
|
||||||
dnf)
|
dnf)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y rustup
|
"$ESCALATION_TOOL" "$PACKAGER" install -y curl rustup man-pages man-db man
|
||||||
;;
|
;;
|
||||||
zypper)
|
zypper)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
|
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
|
||||||
|
@ -54,12 +54,23 @@ installLinutil() {
|
||||||
rustup default stable
|
rustup default stable
|
||||||
cargo install --force linutil_tui
|
cargo install --force linutil_tui
|
||||||
printf "%b\n" "${GREEN}Installed successfully.${RC}"
|
printf "%b\n" "${GREEN}Installed successfully.${RC}"
|
||||||
|
installExtra
|
||||||
;;
|
;;
|
||||||
*) printf "%b\n" "${RED}Linutil not installed.${RC}" ;;
|
*) printf "%b\n" "${RED}Linutil not installed.${RC}" ;;
|
||||||
esac
|
esac
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
installExtra() {
|
||||||
|
printf "%b\n" "${YELLOW}Installing the manpage...${RC}"
|
||||||
|
"$ESCALATION_TOOL" mkdir -p /usr/share/man/man1
|
||||||
|
curl 'https://raw.githubusercontent.com/ChrisTitusTech/linutil/refs/heads/main/man/linutil.1' | "$ESCALATION_TOOL" tee '/usr/share/man/man1/linutil.1' > /dev/null
|
||||||
|
printf "%b\n" "${YELLOW}Creating a Desktop Entry...${RC}"
|
||||||
|
"$ESCALATION_TOOL" mkdir -p /usr/share/applications
|
||||||
|
curl 'https://raw.githubusercontent.com/ChrisTitusTech/linutil/refs/heads/main/linutil.desktop' | "$ESCALATION_TOOL" tee /usr/share/applications/linutil.desktop > /dev/null
|
||||||
|
printf "%b\n" "${GREEN}Done.${RC}"
|
||||||
|
}
|
||||||
|
|
||||||
checkEnv
|
checkEnv
|
||||||
checkEscalationTool
|
checkEscalationTool
|
||||||
checkAURHelper
|
checkAURHelper
|
||||||
|
|
|
@ -61,8 +61,8 @@ installStarshipAndFzf() {
|
||||||
if command_exists fzf; then
|
if command_exists fzf; then
|
||||||
printf "%b\n" "${GREEN}Fzf already installed${RC}"
|
printf "%b\n" "${GREEN}Fzf already installed${RC}"
|
||||||
else
|
else
|
||||||
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
|
git clone --depth 1 https://github.com/junegunn/fzf.git "$HOME/.fzf"
|
||||||
"$ESCALATION_TOOL" ~/.fzf/install
|
"$ESCALATION_TOOL" "$HOME/.fzf/install"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ userinfo () {
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
read -r -p "Please enter username: " username
|
read -r -p "Please enter username: " username
|
||||||
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]
|
if echo "$username" | grep -qE '^[a-z_][a-z0-9_-]{0,31}(\$)?$'
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -267,20 +267,23 @@ userinfo () {
|
||||||
# Loop through user input until the user gives a valid hostname, but allow the user to force save
|
# Loop through user input until the user gives a valid hostname, but allow the user to force save
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
read -r -p "Please name your machine: " name_of_machine
|
printf "%b" "Please name your machine: "
|
||||||
# hostname regex (!!couldn't find spec for computer name!!)
|
read -r machine_name
|
||||||
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
|
|
||||||
|
lower_machine_name=$(echo "$machine_name" | tr '[:upper:]' '[:lower:]')
|
||||||
|
if echo "$lower_machine_name" | grep -q '^[a-z][a-z0-9_.-]\{0,62\}[a-z0-9]$'
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
# if validation fails allow the user to force saving of the hostname
|
# if validation fails allow the user to force saving of the hostname
|
||||||
read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
|
printf "%b" "Hostname doesn't seem correct. Do you still want to save it? (y/N) "
|
||||||
if [[ "${force,,}" = "y" ]]
|
read -r force
|
||||||
|
if [[ "$force" == "y" || "$force" == "Y" ]]
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
export NAME_OF_MACHINE=$name_of_machine
|
export NAME_OF_MACHINE=$lower_machine_name
|
||||||
}
|
}
|
||||||
|
|
||||||
# Starting functions
|
# Starting functions
|
||||||
|
@ -376,7 +379,7 @@ subvolumesetup () {
|
||||||
mountallsubvol
|
mountallsubvol
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "${DISK}" =~ "nvme" ]]; then
|
if echo "$DISK" | grep -q "nvme"; then
|
||||||
partition2=${DISK}p2
|
partition2=${DISK}p2
|
||||||
partition3=${DISK}p3
|
partition3=${DISK}p3
|
||||||
else
|
else
|
||||||
|
|
23
core/tabs/system-setup/system-cleanup.sh
Normal file → Executable file
23
core/tabs/system-setup/system-cleanup.sh
Normal file → Executable file
|
@ -26,16 +26,21 @@ cleanup_system() {
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1
|
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}. Skipping.${RC}"
|
||||||
return 1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
common_cleanup() {
|
common_cleanup() {
|
||||||
"$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete
|
if [ -d /var/tmp ]; then
|
||||||
"$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete
|
"$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete
|
||||||
"$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \;
|
fi
|
||||||
|
if [ -d /tmp ]; then
|
||||||
|
"$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete
|
||||||
|
fi
|
||||||
|
if [ -d /var/log ]; then
|
||||||
|
"$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \;
|
||||||
|
fi
|
||||||
"$ESCALATION_TOOL" journalctl --vacuum-time=3d
|
"$ESCALATION_TOOL" journalctl --vacuum-time=3d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +50,12 @@ clean_data() {
|
||||||
case $clean_response in
|
case $clean_response in
|
||||||
y|Y)
|
y|Y)
|
||||||
printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}"
|
printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}"
|
||||||
find "$HOME/.cache/" -type f -atime +5 -delete
|
if [ -d "$HOME/.cache" ]; then
|
||||||
find "$HOME/.local/share/Trash" -mindepth 1 -delete
|
find "$HOME/.cache/" -type f -atime +5 -delete
|
||||||
|
fi
|
||||||
|
if [ -d "$HOME/.local/share/Trash" ]; then
|
||||||
|
find "$HOME/.local/share/Trash" -mindepth 1 -delete
|
||||||
|
fi
|
||||||
printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}"
|
printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -13,7 +13,7 @@ change_orientation() {
|
||||||
printf "%b\n" "${YELLOW}=========================================${RC}"
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
||||||
printf "%b\n" "${YELLOW} Change Monitor Orientation${RC}"
|
printf "%b\n" "${YELLOW} Change Monitor Orientation${RC}"
|
||||||
printf "%b\n" "${YELLOW}=========================================${RC}"
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
||||||
printf "%b" "${YELLOW}Choose a monitor to configure: ${RC}"
|
printf "%b\n" "${YELLOW}Choose a monitor to configure: ${RC}"
|
||||||
i=1
|
i=1
|
||||||
for monitor in $monitor_array; do
|
for monitor in $monitor_array; do
|
||||||
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
|
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
|
||||||
|
|
|
@ -13,7 +13,7 @@ disable_monitor() {
|
||||||
printf "%b\n" "${YELLOW}=========================================${RC}"
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
||||||
printf "%b\n" "${YELLOW} Disable Monitor${RC}"
|
printf "%b\n" "${YELLOW} Disable Monitor${RC}"
|
||||||
printf "%b\n" "${YELLOW}=========================================${RC}"
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
||||||
printf "%b" "Choose a monitor to disable: "
|
printf "%b\n" "Choose a monitor to disable: "
|
||||||
i=1
|
i=1
|
||||||
for monitor in $monitor_array; do
|
for monitor in $monitor_array; do
|
||||||
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
|
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
|
||||||
|
|
|
@ -13,7 +13,7 @@ enable_monitor() {
|
||||||
printf "%b\n" "${YELLOW}=========================================${RC}"
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
||||||
printf "%b\n" "${YELLOW} Enable Monitor${RC}"
|
printf "%b\n" "${YELLOW} Enable Monitor${RC}"
|
||||||
printf "%b\n" "${YELLOW}=========================================${RC}"
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
||||||
printf "%b" "${YELLOW}Choose a monitor to enable: ${RC}"
|
printf "%b\n" "${YELLOW}Choose a monitor to enable: ${RC}"
|
||||||
|
|
||||||
i=1
|
i=1
|
||||||
for monitor in $monitor_array; do
|
for monitor in $monitor_array; do
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
. ./utility_functions.sh
|
. ../utility_functions.sh
|
||||||
|
|
||||||
. ../../common-script.sh
|
. ../../common-script.sh
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,10 @@ manage_arrangement() {
|
||||||
printf "%b\n" "${YELLOW}=========================================${RC}"
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
||||||
printf "%b\n" "${YELLOW} Manage Monitor Arrangement${RC}"
|
printf "%b\n" "${YELLOW} Manage Monitor Arrangement${RC}"
|
||||||
printf "%b\n" "${YELLOW}=========================================${RC}"
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
||||||
printf "%b" "${YELLOW}Choose the monitor to arrange: ${RC}"
|
printf "%b\n" "${YELLOW}Choose the monitor to arrange: ${RC}"
|
||||||
i=1
|
i=1
|
||||||
for monitor in $monitor_array; do
|
for monitor in $monitor_array; do
|
||||||
printf "%b\n" "$i. ${YELLOW}$monitor${RC}"
|
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
|
||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ set_primary_monitor() {
|
||||||
printf "%b\n" "${YELLOW}Choose a monitor to set as primary:${RC}"
|
printf "%b\n" "${YELLOW}Choose a monitor to set as primary:${RC}"
|
||||||
i=1
|
i=1
|
||||||
for monitor in $monitor_array; do
|
for monitor in $monitor_array; do
|
||||||
printf "%b\n" "$i. ${YELLOW}$monitor${RC}"
|
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
|
||||||
i=$((i + 1))
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../common-script.sh
|
||||||
|
|
||||||
# Check if ~/.ssh/config exists, if not, create it
|
# Check if $HOME/.ssh/config exists, if not, create it
|
||||||
if [ ! -f ~/.ssh/config ]; then
|
if [ ! -f "$HOME/.ssh/config" ]; then
|
||||||
touch ~/.ssh/config
|
touch "$HOME/.ssh/config"
|
||||||
chmod 600 ~/.ssh/config
|
chmod 600 "$HOME/.ssh/config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Function to show available hosts from ~/.ssh/config
|
# Function to show available hosts from $HOME/.ssh/config
|
||||||
show_available_hosts() {
|
show_available_hosts() {
|
||||||
printf "%b\n" "Available Systems:"
|
printf "%b\n" "Available Systems:"
|
||||||
grep -E "^Host " ~/.ssh/config | awk '{print $2}'
|
grep -E "^Host " "$HOME/.ssh/config" | awk '{print $2}'
|
||||||
printf "%b\n" "-------------------"
|
printf "%b\n" "-------------------"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,18 +27,18 @@ ask_for_host_details() {
|
||||||
printf "%b\n" "Host $host_alias"
|
printf "%b\n" "Host $host_alias"
|
||||||
printf "%b\n" " HostName $host"
|
printf "%b\n" " HostName $host"
|
||||||
printf "%b\n" " User $user"
|
printf "%b\n" " User $user"
|
||||||
printf "%b\n" " IdentityFile ~/.ssh/id_rsa"
|
printf "%b\n" " IdentityFile $HOME/.ssh/id_rsa"
|
||||||
printf "%b\n" " StrictHostKeyChecking no"
|
printf "%b\n" " StrictHostKeyChecking no"
|
||||||
printf "%b\n" " UserKnownHostsFile=/dev/null"
|
printf "%b\n" " UserKnownHostsFile=/dev/null"
|
||||||
} >> ~/.ssh/config
|
} >> "$HOME/.ssh/config"
|
||||||
printf "%b\n" "Host $host_alias added successfully."
|
printf "%b\n" "Host $host_alias added successfully."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to generate SSH key if not exists
|
# Function to generate SSH key if not exists
|
||||||
generate_ssh_key() {
|
generate_ssh_key() {
|
||||||
if [ ! -f ~/.ssh/id_rsa ]; then
|
if [ ! -f "$HOME/.ssh/id_rsa" ]; then
|
||||||
printf "%b\n" "SSH key not found, generating one..."
|
printf "%b\n" "SSH key not found, generating one..."
|
||||||
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N "" -C "$(whoami)@$(hostname)"
|
ssh-keygen -t rsa -b 4096 -f "$HOME/.ssh/id_rsa -N" "" -C "$(whoami)@$(hostname)"
|
||||||
else
|
else
|
||||||
printf "%b\n" "SSH key already exists."
|
printf "%b\n" "SSH key already exists."
|
||||||
fi
|
fi
|
||||||
|
@ -150,7 +150,7 @@ move_directory_to_remote() {
|
||||||
remove_system() {
|
remove_system() {
|
||||||
printf "%b\n" "Enter the alias of the host to remove: "
|
printf "%b\n" "Enter the alias of the host to remove: "
|
||||||
read -r host_alias
|
read -r host_alias
|
||||||
sed -i "/^Host $host_alias/,+3d" ~/.ssh/config
|
sed -i "/^Host $host_alias/,+3d" "$HOME/.ssh/config"
|
||||||
printf "%b\n" "Removed $host_alias from SSH configuration."
|
printf "%b\n" "Removed $host_alias from SSH configuration."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,9 +159,9 @@ view_ssh_config() {
|
||||||
printf "%b\n" "Enter the alias of the host to view (or press Enter to view all): "
|
printf "%b\n" "Enter the alias of the host to view (or press Enter to view all): "
|
||||||
read -r host_alias
|
read -r host_alias
|
||||||
if [ -z "$host_alias" ]; then
|
if [ -z "$host_alias" ]; then
|
||||||
cat ~/.ssh/config
|
cat "$HOME/.ssh/config"
|
||||||
else
|
else
|
||||||
grep -A 3 "^Host $host_alias" ~/.ssh/config
|
grep -A 3 "^Host $host_alias" "$HOME/.ssh/config"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<!-- THIS FILE IS GENERATED AUTOMATICALLY. EDIT .github/CONTRIBUTING.md -->\n\n# Contributing Guidelines for Linutil
|
<!-- THIS FILE IS GENERATED AUTOMATICALLY. EDIT .github/CONTRIBUTING.md -->
|
||||||
|
|
||||||
|
# Contributing Guidelines for Linutil
|
||||||
|
|
||||||
Thank you for considering contributing to Linutil! We appreciate your effort in helping improve this project. To ensure that your contributions align with the goals and quality standards of Linutil, please follow these guidelines:
|
Thank you for considering contributing to Linutil! We appreciate your effort in helping improve this project. To ensure that your contributions align with the goals and quality standards of Linutil, please follow these guidelines:
|
||||||
|
|
||||||
|
@ -16,6 +18,7 @@ cd linutil
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. Make your changes
|
## 3. Make your changes
|
||||||
|
|
||||||
- **Edit the files you want to change**: Make your changes to the relevant files.
|
- **Edit the files you want to change**: Make your changes to the relevant files.
|
||||||
- **Test your changes**: Run `cargo run` to test your modifications in a local environment and ensure everything works as expected.
|
- **Test your changes**: Run `cargo run` to test your modifications in a local environment and ensure everything works as expected.
|
||||||
|
|
||||||
|
@ -60,6 +63,7 @@ cd linutil
|
||||||
## 11. Documentation
|
## 11. Documentation
|
||||||
|
|
||||||
- **Update the documentation**: If your change affects the functionality, please update the relevant documentation files to reflect this.
|
- **Update the documentation**: If your change affects the functionality, please update the relevant documentation files to reflect this.
|
||||||
|
- **Automatic generation**: If you decide to add functionality through a new shell script, make sure to fill out all fields in `tab_data.toml` and run `cargo xtask docgen`.
|
||||||
|
|
||||||
## 12. License
|
## 12. License
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{state::ListEntry, theme::Theme};
|
use crate::{state::ListEntry, theme::Theme};
|
||||||
use crossterm::event::{KeyCode, KeyEvent};
|
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
||||||
use ego_tree::NodeId;
|
use ego_tree::NodeId;
|
||||||
use linutil_core::Tab;
|
use linutil_core::Tab;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
@ -116,21 +116,27 @@ impl Filter {
|
||||||
pub fn handle_key(&mut self, event: &KeyEvent) -> SearchAction {
|
pub fn handle_key(&mut self, event: &KeyEvent) -> SearchAction {
|
||||||
//Insert user input into the search bar
|
//Insert user input into the search bar
|
||||||
match event.code {
|
match event.code {
|
||||||
|
KeyCode::Char('c') if event.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||||
|
return self.exit_search()
|
||||||
|
}
|
||||||
KeyCode::Char(c) => self.insert_char(c),
|
KeyCode::Char(c) => self.insert_char(c),
|
||||||
KeyCode::Backspace => self.remove_previous(),
|
KeyCode::Backspace => self.remove_previous(),
|
||||||
KeyCode::Delete => self.remove_next(),
|
KeyCode::Delete => self.remove_next(),
|
||||||
KeyCode::Left => return self.cursor_left(),
|
KeyCode::Left => return self.cursor_left(),
|
||||||
KeyCode::Right => return self.cursor_right(),
|
KeyCode::Right => return self.cursor_right(),
|
||||||
KeyCode::Esc => {
|
|
||||||
self.input_position = 0;
|
|
||||||
self.search_input.clear();
|
|
||||||
return SearchAction::Exit;
|
|
||||||
}
|
|
||||||
KeyCode::Enter => return SearchAction::Exit,
|
KeyCode::Enter => return SearchAction::Exit,
|
||||||
|
KeyCode::Esc => return self.exit_search(),
|
||||||
_ => return SearchAction::None,
|
_ => return SearchAction::None,
|
||||||
};
|
};
|
||||||
SearchAction::Update
|
SearchAction::Update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn exit_search(&mut self) -> SearchAction {
|
||||||
|
self.input_position = 0;
|
||||||
|
self.search_input.clear();
|
||||||
|
SearchAction::Exit
|
||||||
|
}
|
||||||
|
|
||||||
fn cursor_left(&mut self) -> SearchAction {
|
fn cursor_left(&mut self) -> SearchAction {
|
||||||
self.input_position = self.input_position.saturating_sub(1);
|
self.input_position = self.input_position.saturating_sub(1);
|
||||||
SearchAction::None
|
SearchAction::None
|
||||||
|
|
|
@ -119,7 +119,10 @@ impl AppState {
|
||||||
match self.focus {
|
match self.focus {
|
||||||
Focus::Search => (
|
Focus::Search => (
|
||||||
"Search bar",
|
"Search bar",
|
||||||
Box::new([Shortcut::new("Finish search", ["Enter"])]),
|
Box::new([
|
||||||
|
Shortcut::new("Abort search", ["Esc", "CTRL-c"]),
|
||||||
|
Shortcut::new("Search", ["Enter"]),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
|
|
||||||
Focus::List => {
|
Focus::List => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user