mirror of
https://github.com/Matir/skel.git
synced 2026-05-25 21:19:09 -07:00
Misc updates
This commit is contained in:
26
dotfiles/zshrc.d/alert.zsh
Normal file
26
dotfiles/zshrc.d/alert.zsh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
# A function to run a command and send a notification when it's done.
|
||||
# Usage: alert sleep 10
|
||||
|
||||
alert() {
|
||||
# Run the command passed as arguments
|
||||
"$@"
|
||||
|
||||
# Capture the exit code
|
||||
local ret=$?
|
||||
|
||||
# Determine the icon based on success or failure
|
||||
local icon
|
||||
if [ $ret -eq 0 ]; then
|
||||
icon="terminal"
|
||||
else
|
||||
icon="error"
|
||||
fi
|
||||
|
||||
# Send the notification with the executed command
|
||||
notify-send --urgency=low -i "$icon" "Finished: '$@'"
|
||||
|
||||
# Return the original exit code
|
||||
return $ret
|
||||
}
|
||||
@@ -15,3 +15,17 @@ if command -v ffuf >/dev/null 2>&1 ; then
|
||||
alias ffuf-quick="ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/quickhits.txt"
|
||||
fi
|
||||
fi
|
||||
|
||||
if grep --help 2>/dev/null | grep -q 'color'; then
|
||||
# Should have a better way to check for GNU versions
|
||||
alias grep='grep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
fi
|
||||
|
||||
# Detect which `ls` flavor is in use and use the right flag for colors.
|
||||
if ls --help 2>&1 | grep -q -- '--color'; then
|
||||
alias ls='ls --color=auto' # GNU `ls`
|
||||
elif [ "$(uname)" = "Darwin" ]; then
|
||||
alias ls='ls -G' # macOS `ls`
|
||||
fi
|
||||
|
||||
9
dotfiles/zshrc.d/cdgr.zsh
Normal file
9
dotfiles/zshrc.d/cdgr.zsh
Normal file
@@ -0,0 +1,9 @@
|
||||
# Change to the root of the git repository.
|
||||
# If not in a git repo, do nothing.
|
||||
cdgr() {
|
||||
local git_root
|
||||
git_root=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||
if [ -n "$git_root" ]; then
|
||||
cd "$git_root"
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user