Last active
April 8, 2025 14:40
-
-
Save YuanLiou/33e44809235e9f4d6a1e8c4431e13ff5 to your computer and use it in GitHub Desktop.
Ray's fish settings 2.3.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if status is-interactive | |
# Commands to run in interactive sessions can go here | |
end | |
# Oh My Posh | |
oh-my-posh init fish --config ~/.config/ohmyposh/omp.toml | source | |
# Misc | |
set fish_greeting "Hello Fish!" | |
set TERM "xterm-256color" | |
set EDITOR "nvim" | |
export LANG=zh_TW.UTF-8 | |
export LC_ALL=zh_TW.UTF-8 | |
# Alias | |
## Navigation | |
alias ..='cd ..' | |
alias ...='cd ../..' | |
alias .3='cd ../../..' | |
alias .4='cd ../../../..' | |
alias .5='cd ../../../../..' | |
## Others | |
alias cla='lsd -lA --sd' | |
alias cls='lsd' | |
alias cb='swagit' | |
alias ruo='git fetch upstream && git checkout develop && git merge --ff-only upstream/develop && git push origin develop' | |
alias ruom='git fetch upstream && git checkout master && git merge --ff-only upstream/master && git push origin master' | |
alias ruomain='git fetch upstream && git checkout main && git merge --ff-only upstream/main && git push origin main' | |
alias update_master='git fetch upstream && git checkout master && git merge --ff-only upstream/shp_master && git push origin master' | |
alias reload='exec $SHELL -l' | |
alias standup="git log --since '1 day ago' --oneline --pretty=format':%C(yellow) | |
%h %aN%n %B%n' --author Ray" | |
alias RUO='git fetch upstream && git checkout develop && git merge --ff-only upstream/develop && git push origin develop --no-verify' | |
alias vim='mvim -v' | |
alias l='lsd -hA --group-dirs first' | |
alias ex='eza --icons -a --group-directories-first' | |
alias clear="echo 'Use don\'t use clear in Warp'" | |
# Keybinding | |
### Default fish keybinding | |
function fish_user_key_bindings | |
fish_default_key_bindings | |
# fish_vi_key_bindings | |
end | |
# Functions | |
function showLogs | |
git log --pretty=format:'- %s' --since="$1" --author="$2" | |
end | |
# Optimize mp4 | |
# Usage: optimizeVideo video_file | |
function optimizeVideo | |
set video_file $argv[1] | |
ffmpeg -i "$video_file" -vcodec h264 -acodec mp2 "$video_file.mp4" | |
end | |
# Convert video to gif file. | |
# Usage: video2gif video_file (scale) (fps) | |
function video2gif | |
set video_file $argv[1] | |
set scale (count $argv) >= 3 ? $argv[2] : 320 | |
set fps (count $argv) >= 4 ? $argv[3] : 10 | |
ffmpeg -y -i "$video_file" -vf fps=$fps,scale=$scale:-1:flags=lanczos,palettegen "$video_file.png" | |
ffmpeg -i "$video_file" -i "$video_file.png" -filter_complex "fps=$fps,scale=$scale:-1:flags=lanczos[x];[x][1:v]paletteuse" "$video_file.gif" | |
rm "$video_file.png" | |
end | |
# Convert HDR video to SDR Video | |
function removeHdr | |
set video_file $argv[1] | |
ffmpeg -i "$video_file" -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:v libx265 -crf 22 -preset medium -tune fastdecode "$video_file.mp4" | |
end | |
# Adb device chooser, install fzf first | |
function adb | |
# Get the total number of devices connected | |
set totalLines (command adb devices | wc -l | xargs) | |
set totalDeviceConnected (math $totalLines - 2) | |
# Check if more than one device is connected and if the `-s` flag is not passed | |
if not string match -q -- "*-s*" "$argv" and test $totalDeviceConnected -gt 1 | |
# Get the list of connected devices, excluding empty lines | |
set devices (command adb devices | awk '$2 == "device" {print $1}' | grep -v '^$') | |
set devicesText "" | |
# Loop through each device | |
for device in $devices | |
# Get the market name property for the device | |
set market_name (command adb -s $device shell getprop ro.product.vendor.marketname) | |
# If market name is empty, get the model property instead | |
if test -z "$market_name" | |
set market_name (command adb -s $device shell getprop ro.product.model) | |
end | |
# Append device and market name to the devicesText | |
set devicesText "$devicesText$device - $market_name\n" | |
end | |
# Use fzf to prompt the user to select a device, filtering out empty lines | |
set selection (echo -e $devicesText | grep -v '^$' | fzf) | |
set deviceId (echo $selection | awk '{print $1}') | |
# Set color variables | |
set GREEN "\033[0;32m" | |
set NC "\033[0m" # No Color | |
# Print the selected device | |
echo -e "π± Device Selected: $GREEN$selection$NC" | |
# Pass the adb command with the selected device | |
command adb -s $deviceId $argv | |
else | |
# Execute the command without device selection | |
command adb $argv | |
end | |
end | |
# Gradle Utils Functions | |
# Get the size of gradle caches, wrappers, and daemons in human readable format | |
# Depends on: du, awk | |
# Use as: gradleSize | |
function gradleSize | |
set DIR_TO_CHECK "caches" "wrapper" "daemon" | |
for dir in $DIR_TO_CHECK | |
printf " π ~/.gradle/$dir: " | |
du -sh ~/.gradle/$dir | awk '{ print $1 }' | |
end | |
end | |
# Clean up the gradle caches, wrappers, and daemons directory of files | |
# that were accessed more than 30 days ago and remove empty directories | |
# Depends on: gradleSize | |
# Use as: gradleFree | |
function gradleFree | |
echo " [BEFORE Cleanup] Gradle caches size:" | |
gradleSize | |
echo "==========================================================" | |
echo " Cleaning up gradle directories ..." | |
echo " " | |
echo " Working in:" | |
set DIR_TO_CHECK "caches" "wrapper" "daemon" | |
for dir in $DIR_TO_CHECK | |
echo " π ~/.gradle/$dir" | |
# Delete all files accessed 30 days ago | |
find ~/.gradle/$dir -type f -atime +30 -delete | |
# Delete empty directories | |
find ~/.gradle/$dir -mindepth 1 -type d -empty -delete | |
end | |
echo "==========================================================" | |
echo " [AFTER Cleanup] Gradle caches size:" | |
gradleSize | |
echo "==========================================================" | |
echo " Done β " | |
end | |
# endregion Function | |
# The fuck alias | |
eval $(thefuck --alias zz) | |
# Import with path | |
# Rust | |
export PATH="$HOME/.cargo/bin:$PATH" | |
# Emacs | |
export PATH="$HOME/.config/emacs/bin:$PATH" | |
# Fix fish integration with iTerm | |
function fish_mode_prompt | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment