Skip to content

Instantly share code, notes, and snippets.

@henri
Last active July 3, 2024 02:27
Show Gist options
  • Save henri/4f034f04b35c01e089e98350c902bda8 to your computer and use it in GitHub Desktop.
Save henri/4f034f04b35c01e089e98350c902bda8 to your computer and use it in GitHub Desktop.
fish snippits
# set random_value to be integer less than 100 # fails in BASH!
random_value=`random 1 100`
#!/usr/bin/env fish
#
# Script to overide the default fish_title function
#
# Copyright Henri Shustak 2024
# Released under the GNU GLP v3 or later :
# https://www.gnu.org/licenses/gpl.html
#
# This function is an overide wrapper for the fish_title.fish function
# Installation : copy into your fish functions directory :
# ~/.config/fish/functions/
#
# Start a new shell and source the script. Example usage below :
# source ~/.config/fish/functions/fish_title.fish "My New Title"
#
# Setup an alias for this using the following commands :
# alias set_title="source ~/.config/fish/functions/fish_title.fish"
# funcsave set_title
#
# Then you can use this function with this command :
# set_title "My Amazing Title" # sets the title to "My Amazing Title"
# set_title # reverts to default fish tile
#
set new_title $argv[1]
if [ "$new_title" != "" ]
# specify a specific custom fish_title function using the argument as part of this new title
function fish_title ; set -q argv[1]; or set argv ; echo "$new_title" ; end
else
# revert to default fish_title function or something else you like
# use 'functions -D fish_title' to show the path to your fish_title function
# function fish_title ;set -q argv[1]; or set argv fish ; echo (fish_prompt_pwd_dir_length=1 prompt_pwd): $argv; end
source /usr/share/fish/functions/fish_title.fish
end
# from : https://www.reddit.com/user/jorbleshi_kadeshi/
# save this into : .config/fish/functions/wa.fish
# and add your APPID
function wa
set --local APPID "YOURAPPIDHERE" # Get one at https://products.wolframalpha.com/api/
echo $argv | string escape --style=url | read question_string
set --local url "https://api.wolframalpha.com/v1/result?appid="$APPID"&i="$question_string
curl -s $url
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment