alias forgethist=unset HISTFILE
Useful when I run the same two commands 20 times in a row
alias forgethist=unset HISTFILE
Useful when I run the same two commands 20 times in a row
These are some pacman+fzf implementations from the arch wiki + a flatpak implementation i did with fzf(still needs some polish but it works).
alias pacq=$'pacman -Q | fzf'
alias pacs=$'pacman -Slq | fzf --multi --preview 'pacman -Si {1}' | xargs -ro sudo pacman -S'
alias pacr=$'pacman -Qq | fzf --multi --preview 'pacman -Si {1}' | xargs -ro sudo pacman -Rns'
alias flatr=$'flatpak list | fzf --preview 'flatpak info {2} ' | grep -Eo '[a-ZA-Z]+.[^ ]+' |awk '{print $1}' | xargs -ro flatpak remove --delete-data'
This is a separate reply since I didn't know that you can include shell functions here.
I made this little function read_latest_log()
because I just want to "read the latest log file" in a directory full of timestamped log files. I made a helper function separator_line_with_text()
to help with the output, basically setting off the file-info portion (just the filename for now) from the file contents.
# # separator_line_with_text
# # Centers text in a separator line
# #
# # Usage:
# # separator_line_with_text «separator_char» «text»
separator_line_with_text() {
local separator_char="$1"
local contents_str="$2"
# Calculate separator_length
local separator_length=$(( $(tput cols) - 2 - ${#contents_str} ))
# Calculate the width of the left and right parts of the separator line
local half_line_width=$(( (${separator_length}) / 2 ))
# Construct the separator line using the $separator_char and $contents_str
for ((i = 0; i « half_line_width; i++))
do
echo -n ${separator_char}
done
echo -n ${contents_str}
for ((i = 0; i < half_line_width; i++))
do
echo -n ${separator_char}
done
echo ""
}
# # read_latest_log
# # Reads the latest log file with a timestamp in the filename.
# #
# # Usage:
# # read_latest_log [[«name_filter»] «extension»] «separator» «timestamp_field_number»
read_latest_log () {
# Check if the function has sufficient parameters
if [[ $# -lt 2 ]]; then
echo "Error: insufficient parameters."
echo "Usage: read_latest_log [[«name_filter» = *] [«extension» = log] «separator» «timestamp_field_number»"
return 1
fi
# Supposing only two parameters are provided
# «name_filter» parameter is "*"
# «extension» parameter is "log"
if [[ $# -eq 2 ]]; then
local name_filter="*"
local extension="log"
local separator="$1"
local field="$2"
fi
# Supposing only three parameters are provided,
# assume that the «name_filter» parameter is "*"
if [[ $# -eq 3 ]]; then
local name_filter="*"
local extension="$1"
local separator="$2"
local field="$3"
fi
# If all parameters are provided, assign them accordingly
if [[ $# -eq 4 ]]; then
local name_filter="$1"
local extension="$2"
local separator="$3"
local field="$4"
fi
# Find all log files with the specified extension, sort them based on the separator and field
local log_files=$(find . -type f -name "${name_filter}.${extension}" | sort -n -t "${separator}" -k "${field}")
# If no log files are found, display a message and return
if [[ -z "$log_files" ]]; then
echo "No log files found."
return 0
fi
# Get the latest log file and its full path
local latest_log_file=$(echo "$log_files" | tail -1)
local full_path=$(realpath "$latest_log_file")
# Define the strings for the separator line and
# calculate the appropriate length of the separator line
local contents_str=" Contents "
local separator_char="—"
separator_line_with_text ${separator_char} ""
separator_line_with_text " " ${full_path}
separator_line_with_text ${separator_char} ${contents_str}
cat "$(echo "$log_files" | tail -1)"
}
Sorry for all the edits, for some reason anything that looks like an HTML tag gets erased.
alias clear="clear; fastfetch"
alias sudo="doas"
alias clr="clear"
alias kx="killall Xwayland"
alias vpython="~/newVenv/bin/python"
alias vpip="~/newVenv/bin/pip"
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0