feat: add pstf function

This commit is contained in:
jabuxas 2024-11-16 13:13:21 -03:00
parent ec6c3a92fd
commit d7c3ccf90f
3 changed files with 34 additions and 13 deletions

View File

@ -20,13 +20,18 @@ if status is-interactive
alias reboot="systemctl reboot" alias reboot="systemctl reboot"
alias hr="date +'%Hh:%M, %d-%m-%Y'" alias hr="date +'%Hh:%M, %d-%m-%Y'"
alias hi="systemctl hibernate" alias hi="systemctl hibernate"
alias ff="fastfetch" alias ff="fastfetch --config examples/19"
alias feh="imv" alias feh="imv"
alias lg="lazygit" alias lg="lazygit"
alias cpr="cd ~/repos/cports-docker && docker compose run --build --rm cports" alias cpr="cd ~/repos/cports-docker && docker compose run --build --rm cports"
alias cop="wl-copy" alias cop="wl-copy"
alias poweroff="systemctl poweroff" alias poweroff="systemctl poweroff"
alias cat="bat" alias cat="bat"
alias protontricks='flatpak run com.github.Matoking.protontricks'
alias protontricks-launch='flatpak run --command=protontricks-launch com.github.Matoking.protontricks'
alias generate_token="curl -u jabuxas https://paste.jabuxas.xyz | wl-copy"
end end
function pst function pst
@ -55,6 +60,32 @@ function pst
end end
end end
function pstf
set -l file
set -l use_ansifilter false
if command -v ansifilter > /dev/null
set use_ansifilter true
end
if command test -p /dev/stdin
set file "/tmp/tmp.txt"
if test $use_ansifilter = true
ansifilter > $file
else
cat > $file
end
else if test -n "$argv[1]"
set file "$argv[1]"
end
curl -F "file=@$file" -Fsecret= -H "X-Auth: $(cat ~/.key)" https://paste.jabuxas.xyz
if command test -p /dev/stdin
rm "$file"
end
end
function last_history_item function last_history_item
echo $history[1] echo $history[1]
end end

View File

@ -26,7 +26,7 @@ SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrbl
SETUVAR fish_color_status:red SETUVAR fish_color_status:red
SETUVAR fish_color_user:brgreen SETUVAR fish_color_user:brgreen
SETUVAR fish_color_valid_path:\x2d\x2dunderline SETUVAR fish_color_valid_path:\x2d\x2dunderline
SETUVAR fish_key_bindings:fish_vi_key_bindings SETUVAR fish_key_bindings:fish_default_key_bindings
SETUVAR fish_pager_color_background:\x1d SETUVAR fish_pager_color_background:\x1d
SETUVAR fish_pager_color_completion:B3A06D SETUVAR fish_pager_color_completion:B3A06D
SETUVAR fish_pager_color_description:B3A06D SETUVAR fish_pager_color_description:B3A06D

View File

@ -65,20 +65,10 @@ fi
pst() { pst() {
local file local file
local use_ansifilter=false
# Check if ansifilter exists
if command -v ansifilter >/dev/null 2>&1; then
use_ansifilter=true
fi
if [[ -p /dev/stdin ]]; then if [[ -p /dev/stdin ]]; then
file=$(mktemp) file=$(mktemp)
if $use_ansifilter; then
ansifilter > "$file"
else
cat > "$file" cat > "$file"
fi
elif [[ -n $1 ]]; then elif [[ -n $1 ]]; then
file="$1" file="$1"
else else