mirror of
https://github.com/Matir/skel.git
synced 2026-05-25 21:19:09 -07:00
Misc updates
This commit is contained in:
65
dotfiles/config/fish/conf.d/aliases.fish
Normal file
65
dotfiles/config/fish/conf.d/aliases.fish
Normal file
@@ -0,0 +1,65 @@
|
||||
# This script reads a bash-formatted alias file (~/.aliases) and creates
|
||||
# equivalent fish aliases. This allows for sharing aliases between bash and fish.
|
||||
|
||||
# Path to the bash alias file
|
||||
set bash_alias_file ~/.aliases
|
||||
|
||||
# Check if the alias file exists
|
||||
if test -f "$bash_alias_file"
|
||||
# Read the file line by line
|
||||
while read -l line
|
||||
# Skip comments and empty lines
|
||||
if string match -q -r '^\s*#' "$line" || test -z "$line"
|
||||
continue
|
||||
end
|
||||
|
||||
# Check if the line defines an alias
|
||||
if string match -q -r '^\s*alias\s+' "$line"
|
||||
# Remove the 'alias ' prefix
|
||||
set -l definition (string replace -r '^\s*alias\s+' '' "$line")
|
||||
|
||||
# Split the definition into name and value at the first '='
|
||||
set -l parts (string split -m 1 '=' "$definition")
|
||||
set -l alias_name $parts[1]
|
||||
set -l alias_value $parts[2]
|
||||
|
||||
# Remove leading/trailing quotes from the value
|
||||
set -l alias_value (string trim -c "'"" "$alias_value")
|
||||
|
||||
# Define the fish alias
|
||||
alias $alias_name "$alias_value"
|
||||
end
|
||||
end < "$bash_alias_file"
|
||||
end
|
||||
|
||||
# Specific aliases that are not in the bash file
|
||||
|
||||
# On some systems, bat is batcat
|
||||
if not command -v bat >/dev/null 2>&1
|
||||
if command -v batcat >/dev/null 2>&1
|
||||
alias bat (command -v batcat)
|
||||
end
|
||||
end
|
||||
|
||||
# FFUF aliases
|
||||
if command -v ffuf >/dev/null 2>&1
|
||||
if test -d $HOME/tools/seclists
|
||||
alias ffuf-files "ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/raft-large-files.txt"
|
||||
alias ffuf-dirs "ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/raft-large-directories.txt"
|
||||
alias ffuf-quick "ffuf -c -w $HOME/tools/seclists/Discovery/Web-Content/quickhits.txt"
|
||||
end
|
||||
end
|
||||
|
||||
if grep --help 2>/dev/null | grep -q 'color'
|
||||
# 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'
|
||||
end
|
||||
|
||||
# Detect which `ls` flavor is in use and use the right flag for colors.
|
||||
if ls --help 2>&1 | grep -q -- '--color'
|
||||
alias ls 'ls --color=auto' # GNU `ls`
|
||||
else if test (uname) = "Darwin"
|
||||
alias ls 'ls -G' # macOS `ls`
|
||||
end
|
||||
@@ -7,6 +7,11 @@ if test -x /opt/homebrew/bin/brew
|
||||
if test -d (brew --prefix)"/share/fish/vendor_completions.d"
|
||||
set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d
|
||||
end
|
||||
|
||||
# mise, if installed
|
||||
if type -q mise
|
||||
mise hook fish | source
|
||||
end
|
||||
end
|
||||
|
||||
if command -q starship
|
||||
|
||||
8
dotfiles/config/fish/functions/cdgr.fish
Normal file
8
dotfiles/config/fish/functions/cdgr.fish
Normal file
@@ -0,0 +1,8 @@
|
||||
# Change to the root of the git repository.
|
||||
# If not in a git repo, do nothing.
|
||||
function cdgr
|
||||
set git_root (git rev-parse --show-toplevel 2>/dev/null)
|
||||
if test -n "$git_root"
|
||||
cd "$git_root"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user