Skip to content

Instantly share code, notes, and snippets.

@henri
Last active July 15, 2025 04:24
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

fish snippits

This gist contines snippits of fish code snippits, functions and usage tips to make swimming with fish a little easier.

spb specific snippits

Many of these fish snippits are specific to SPB (Start Private Browser) a project for starting multiple instances of a web browser.

Below you will also find an installer file and a kick off file. Coping the lines from the kick off file into a terminal will start the installation of the spb fish functions and alias. If you install via the SPB install script and already have the fish shell installed on your system, then during the install you will be prompted to update/install these spb related fish snippits.

With these spb specific fish functions configured. Initating web searches and conversations from the shell will get you moving fast in the current. As such searching for realivent information in the vast oceans of the inerent will hopefully be a little easier each day.

The newest of these is a function for starting multiple converstations with perplexity ai in a private browser window using SPB.

Have fun swimming 🐠

# basic
cd /path/to/dir 2> /dev/null ; or echo "unable to move to the path!" && exit -1
# set random_value to be integer less than 100 # fails in BASH!
random_value=`random 1 100`
# read file in and print each line with a while loop
cat /path/to/my.file | while read -l line ; echo $line ; end
while read -l line ; echo $line ; end < /path/to/my.file
# move to directory or fail (using or in fish shell one liners)
cd /path/to/move/to 2> /dev/null ; or echo "unable to move to specificed path!" && exit -1
# link to fish config :
https://gist.github.com/henri/bfb800d047a910fe30fec6872c7ee63a
# call from fish_prompt.fish to show if the ssh-agent enviroment varable is missing in your right in your prompt.
function fish_ssh_agent_enviroment
set -l agent_status ""
if test -z "$SSH_AUTH_SOCK"
set agent_status " (ssh-agent?)"
end
echo -n $agent_status
end
# if you do not haev a fish_prompt.fish file already, you may make one by issuein the command below as you (not as root)
# functions fish_prompt >> ~/.config/fish/functions/fish_prompt.fish
#!/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
# one line command to configure spb-brave-ai functioin to start multiple Brave Search AI (Leo) summerized searches in multiple private browser tabs.
# this function requires spb (start-private-browser) alias to be configured : https://gist.github.com/henri/34f5452525ddc3727bb66729114ca8b4
# this function requires an alias 'start-private-browser' and 'spb' to be setup eg :
# alias --save start-private-browser="~/bin/start-private-browser.bash"
# alias --save spb="start-private-browser"
# run the following in a fish shell to configure for your shell :
# OLD : function spb-brave-ai ; set urls ( while test (count $argv) -gt 0 ; echo "https://search.brave.com/search?q=$argv[1]&summary=1&conversation" | tr " " "+" ; set --erase argv[1] ; end ) ; spb $urls ; end ; funcsave spb-brave-ai
# run the following in a fish shell to configure for your shell :
function spb-brave-ai
set urls (
while test (count $argv) -gt 0
switch $argv[1]
case '--template' '--new-template' '--edit-template' '--force-stop'
echo "$argv[1]"
echo "$argv[2]"
set --erase argv[1]
case '--help' '--list' '-ls' '-l' '--list-templates' '--update'
echo "$argv[1]"
break
case '--standard' '--quite'
echo "$argv[1]"
case '*'
echo (echo "https://search.brave.com/search?q=$argv[1]&summary=1&conversation" | tr " " "+")
end
set --erase argv[1]
end
)
spb $urls
end
funcsave spb-brave-ai
# usage example - lets say you want to start two chats. The first chat "tell me about cats" and have a second chat "tell me about the largest cats"
# spb-brave-ai "tell me about cats" "tell me about the largest cats"
# starting a chat in a private browser window with Brave Search Summerisation powered by Leo (Brave's AI chatbot)
# note : this command offers basic support for special characters. The only subsittion is space characters are turned into plus signs. If you are searching
# for something with odd characters then probably using this script is not a great idea.
# todo : turn this into a fisher package rather than a gist
# one line command to configure spb-brave functioin to start multiple Brave Searchs in multiple private browser tabs.
# this function requires spb (start-private-browser) alias to be configured : https://gist.github.com/henri/34f5452525ddc3727bb66729114ca8b4
# this function requires an alias 'start-private-browser' and 'spb' to be setup eg :
# alias --save start-private-browser="~/bin/start-private-browser.bash"
# alias --save spb="start-private-browser"
# run the following in a fish shell to configure for your shell :
# OLD : function spb-brave ; set urls ( while test (count $argv) -gt 0 ; echo "https://search.brave.com/search?q=$argv[1]" | tr " " "+" ; set --erase argv[1] ; end ) ; spb $urls ; end ; funcsave spb-brave
# run the following in a fish shell to configure for your shell :
function spb-brave
set urls (
while test (count $argv) -gt 0
switch $argv[1]
case '--template' '--new-template' '--edit-template' '--force-stop'
echo "$argv[1]"
echo "$argv[2]"
set --erase argv[1]
case '--help' '--list' '-ls' '-l' '--list-templates' '--update'
echo "$argv[1]"
break
case '--standard' '--quite'
echo "$argv[1]"
case '*'
echo (echo "https://search.brave.com/search?q=$argv[1]" | tr " " "+")
end
set --erase argv[1]
end
)
spb $urls
end
funcsave spb-brave
# usage example - lets say you want to start two searchs. The first chat "tell me about cats" and have a second chat "tell me about the largest cats"
# spb-brave "tell me about cats" "tell me about the largest cats"
# starting two searches in a private browser window using Brave Search
# note : this command offers basic support for special characters. The only subsittion is space characters are turned into plus signs. If you are searching
# for something with odd characters then probably using this script is not a great idea.
# todo : turn this into a fisher package rather than a gist
# one line command to configure spb-ddg-ai functioin to start multiple DuckDuckGo AI a chats in multiple private browser tabs.
# this function requires spb (start-private-browser) alias to be configured : https://gist.github.com/henri/34f5452525ddc3727bb66729114ca8b4
# this function requires an alias 'start-private-browser' and 'spb' to be setup eg :
# alias --save start-private-browser="~/bin/start-private-browser.bash"
# alias --save spb="start-private-browser"
# run the following in a fish shell to configure for your shell :
function spb-ddg-ai
set urls (
while test (count $argv) -gt 0
switch $argv[1]
case '--template' '--new-template' '--edit-template' '--force-stop'
echo "$argv[1]"
echo "$argv[2]"
set --erase argv[1]
case '--help' '--list' '-ls' '-l' '--list-templates' '--update'
echo "$argv[1]"
break
case '--standard' '--quite'
echo "$argv[1]"
case '*'
echo (echo "https://duckduckgo.com/?t=h_&q=$argv[1]&ia=chat&bang=true" | tr " " "+")
end
set --erase argv[1]
end
)
spb $urls
end
funcsave spb-ddg-ai
# usage example - lets say you want to start two chats. The first chat "tell me about cats" and have a second chat "tell me about the largest cats"
# spb-ddg-ai "tell me about cats" "tell me about the largest cats"
# starting a chat in a private browser window with DuckDuckGo AI chat, will require agreeing to DuckDuckGo usage policies with a number of clicks at the moment using the mouse.
# hopefully DuckDuck go will offer a way to include approval in the URL in the future.
# note : this command offers basic support for special characters. The only subsittion is space characters are turned into plus signs. If you are searching
# for something with odd characters then probably using this script is not a great idea.
# todo : turn this into a fisher package rather than a gist
# one line command which setups up spb-ddg as a command to search Duck Duck Go with provided search arguments in a private browser
# this function requires spb (start-private-browser) alias to be configured : https://gist.github.com/henri/34f5452525ddc3727bb66729114ca8b4
# this function requires an alias 'start-private-browser' and 'spb' to be setup eg :
# alias --save start-private-browser="~/bin/start-private-browser.bash"
# alias --save spb="start-private-browser"
# run the following in a fish shell to configure for your shell :
# OLD : function spb-ddg ; set urls ( while test (count $argv) -gt 0 ; echo "https://duckduckgo.com/?t=h_&q=$argv[1]" | tr " " "+" ; set --erase argv[1] ; end ) ; spb $urls ; end ; funcsave spb-ddg
# run the following in a fish shell to configure for your shell :
function spb-ddg
set urls (
while test (count $argv) -gt 0
switch $argv[1]
case '--template' '--new-template' '--edit-template' '--force-stop'
echo "$argv[1]"
echo "$argv[2]"
set --erase argv[1]
case '--help' '--list' '-ls' '-l' '--list-templates' '--update'
echo "$argv[1]"
break
case '--standard' '--quite'
echo "$argv[1]"
case '*'
echo (echo "https://duckduckgo.com/?t=h_&q=$argv[1]" | tr " " "+")
end
set --erase argv[1]
end
)
spb $urls
end
funcsave spb-ddg
# usage example to open private browser and search for "search for hello world" and "search this big world" in two DuckDuck Go tabs.
# spb-ddg "search for hello world" "search this big world"
# note : this command is not complex only space characters are turned into plus signs. If you are searching
# for something with odd characters then probably using this script is not a great idea.
# todo : turn this into a fisher package rather than a gist
# copy and paste the lines below into a bash shell to setup the spb fish functions listed in this gist.
/bin/bash -c "$(curl -fsSL \
https://gist.githubusercontent.com/henri/\
4f034f04b35c01e089e98350c902bda8/raw/\
spb-fish-function-installer.bash)"
# note this is until a fisher setup is established.
#!/usr/bin/env bash
#
# (C)Copyright Henri Shustak 2025
# Licenced Under the GNU GPL v3 or later
# https://www.gnu.org/licenses/gpl-3.0.en.html
#
# Simple build script to install
# the spb fish alias onto your system
#
# This script downloads and the
# files from this URL :
# https://gist.github.com/henri/4f034f04b35c01e089e98350c902bda8
#
# Initial release only supports fish shell functions.
#
# version 1.0 - initial release
# version 1.1 - bug fixes
# version 1.2 - added check so we do not overwrite existing spb fish alias
# this making custom option overriding a little easier
# version 1.3 - bug fixes
# version 1.4 - further bug fixes
# version 1.5 - additional improvments to script reliability on different operating systems
# version 1.6 - included support for updating start-private-browser fish alias
# version 1.7 - additional bug fixes
# version 1.8 - improved check mark box cross platform compatibility
# version 1.9 - improveed resect of overwrite checking enviroment variable to support auto updates
# version 2.0 - improved logging of clone operation for unattended executuoin logging
# configuration
SPB_BUILD_DIRECTORY_NAME="spb-build-fish-functions"
SPB_DOWNLOAD_DIRECTORY_NAME="spb-fish-functions-latest"
# link to gist which has all the data
fish_spb_snippits_gist_link="https://gist.github.com/henri/4f034f04b35c01e089e98350c902bda8"
# list of fish functions to load from this gist # this list is not including alias such as 'spb' and 'start-private-browser'
# do not add spb.fish - that will overwrite the way people customise their settings. BADBADBAD!
functions_to_load="
spb-yt.fish
spb-perlexity-ai.fish
spb-ddg.fish
spb-ddg-ai.fish
spb-tor.fish
spb-brave.fish
spb-brave-ai.fish
"
# special symbold
tick_mark='\xE2\x9C\x94'
bullet_mark='\xE2\x80\xA2'
# setup enviroment varibles
if [[ "${SPB_FISH_FUNCTION_SKIP_OVERWRITE_CHECK}" != "true" ]] ; then
# SPB_SKIP_OVERWRITE_CHECK enviroment varible not detected ; set to false (default)
SPB_FISH_FUNCTION_SKIP_OVERWRITE_CHECK="false"
fi
which git >> /dev/null ; git_available=${?}
if [[ ${git_available} != 0 ]] ; then
echo "ERROR! : The git command was not detected on your system."
echo " Ensure it is part of your path or install git onto your"
echo " system and try running this installer again."
echo ""
echo " Learn more about git the link below :"
echo " https://git-scm.com/"
exit -99
fi
which fish >> /dev/null ; fish_available=${?}
if [[ ${fish_available} != 0 ]] ; then
echo "ERROR! : The fish shell was not detected on your system."
echo " Ensure it is part of your path or install fish onto your"
echo " system and try running this installer again."
echo ""
echo " Learn more about the fish shell via the link below :"
echo " https://fishshell.com/"
exit -99
fi
# create a build directory, we will be sucking down the latest version of
# everything from git into this directory, then to clean up, we can delete :)
cd $( mktemp -d /tmp/${SPB_BUILD_DIRECTORY_NAME}.XXXXXXX )
if [[ $? != 0 ]] ; then
echo "ERROR! : Unable to setup the temporary build dirctory!"
exit -99
fi
# double sanity check (not needed) but lets avoid deleting anything important by mistake when we clean up
temporary_build_directory="$(pwd)"
if ! [[ $(echo "$(basename ${temporary_build_directory})" | grep "${SPB_BUILD_DIRECTORY_NAME}") ]] ; then
echo "ERROR! : Unable to succesfully locate the temporary directory"
exit -99
fi
# report the temporary build directory :
echo ""
echo "This script has created a temporay build directory : "
echo "$(pwd)"
echo ""
# clone a copy of the latest version into the temp directory
echo "Downloading latest SPB fish functions ..."
git clone --progress --depth 1 --single-branch --branch=main ${fish_spb_snippits_gist_link} ${SPB_DOWNLOAD_DIRECTORY_NAME} 2>&1
if [[ $? != 0 ]] ; then
echo ""
echo "ERROR! : Sucking down latest version from git!"
echo " It is likely that git is not installed on"
echo " this system or there is a problem with"
echo " network access or possibly GitHub has"
echo " crashed or has been blocked?"
echo ""
echo " I am sure you will sort it out!"
exit -98
fi
# check if any spb functions are already setup (do it before the trap is enabled)
existing_spb_functions_return_code=$( fish -c ' "functions" | grep -E "^spb" > /dev/null ; echo $status ' )
existing_and_home_bin_start_private_browser_alias_return_code=$( cat ~/.config/fish/functions/start-private-browser.fish 2> /dev/null | grep '~/bin/start-private-browser.bash $argv' > /dev/null ; echo $? )
existing_start_private_browser_alias_return_code=$( ls ~/.config/fish/functions/start-private-browser.fish 2>&1 > /dev/null ; echo $? )
existing_spb_alias_return_code=$( fish -c ' "alias" | grep -E "^alias spb " > /dev/null ; echo $status ' )
# preform exit if we hit an error ; in addition set an EXIT trap
trap 'echo "" ; echo "Something went horribly wrong! Sorry please try again later." ; echo ""' EXIT
set -e
# enter the local repo
pwd
cd ${SPB_DOWNLOAD_DIRECTORY_NAME}
# check if spb is installed?
if ! [[ -f ~/bin/start-private-browser.bash ]] ; then
echo "ERROR! : unable to locate the required start-private-browser.bash file on your system"
echo " visit : http://github.com/henri for more information and installation instructions"
exit -99
fi
function abort_fish_function_setup () {
echo ""
echo "Understood.. fish spb funtion setup aborted."
echo ""
# clear EXIT trap and exit (with error) - installation did not complete succesfully.
trap - EXIT ; exit -2
}
function create_or_update_start_private_browser_alias() {
# that last funcsave is not needed but it seems to help sometimes.
echo " fish alias : 'start-private-browser ->~/bin/start-private-browser.bash' :"
fish -c "alias -s start-private-browser=\"~/bin/start-private-browser.bash\" 2> /dev/null && funcsave start-private-browser"
if [[ ${?} == 0 ]] ; then
echo -e " ${tick_mark} [ configured successfully ]"
echo ""
else
echo " x [ error during setup ]"
echo ""
exit -65
fi
}
# install an alias for start-private-browser -> ~/bin/start-private-browser.bash
echo ""
echo "Fish alias related to SPB (start-private-browser) : "
echo ""
if [[ "${SPB_FISH_FUNCTION_SKIP_OVERWRITE_CHECK}" == "true" ]] ; then
echo ""
echo " WARNING! : SPB_FISH_FUNCTION_SKIP_OVERWRITE_CHECK = true"
echo " WARNING! : Overwriting existing fish aliases"
echo ""
fi
if [[ ${existing_and_home_bin_start_private_browser_alias_return_code} == 0 ]] ; then
echo " fish alias : 'start-private-browser -> ~/bin/start-private-browser.bash' :"
echo -e " ${tick_mark} [ skipped ] already configured (exact match)"
echo ""
else
if [[ "${SPB_FISH_FUNCTION_SKIP_OVERWRITE_CHECK}" != "true" ]] ; then
if [[ ${existing_start_private_browser_alias_return_code} == 0 ]] ; then
echo " fish alias : 'start-private-browser -> ~/bin/start-private-browser.bash' :"
echo " [detected] ***NOT*** configured to use : ~/bin/start-private-browser.bash "
echo ""
echo " current alias configuration : "
# display the current start-private-browser alias setup (if a user has lots of aliass configured this may take a moment
fish -c "alias | grep 'alias start-private-browser '" | awk '{print $2 " -> " $3}' | sed 's/^/ /'
echo ""
echo " to manually reconfigure the start-private-browser alias to point"
echo " to the copy of SPB in your home directory use the following command : "
echo ""
echo " alias start-private-browser '~/bin/start-private-browser.bash'"
echo ""
echo " WARNING! : if you continue your existing 'start-private-browser' alias will be overwritten!"
echo -n " overwrite your alias start-private-browser alias [Y/n] : "
read option_to_bottle_out
if \
[[ "${option_to_bottle_out}" == "n" ]] || \
[[ "${option_to_bottle_out}" == "N" ]] || \
[[ "${option_to_bottle_out}" == "no" ]] || \
[[ "${option_to_bottle_out}" == "No" ]] || \
[[ "${option_to_bottle_out}" == "NO" ]] \
; then
abort_fish_function_setup
fi
create_or_update_start_private_browser_alias
else
create_or_update_start_private_browser_alias
fi
else
create_or_update_start_private_browser_alias
fi
fi
echo ""
# install an alias for spb -> start-private-browser (yep we do that as well)
if [[ ${existing_spb_alias_return_code} == 0 ]] ; then
echo " fish alias : 'spb -> start-private-browser' :"
echo -e " ${tick_mark} [ skipped ] already configured (exact matching is not checked)"
else
# no existing spb fish alias configured ; so we setup the alias
echo "fish alias : 'spb -> start-private-browser' : "
echo " [ configuring ] no previous configuration detected"
fish -c "source ./spb.fish > /dev/null"
if [[ ${?} == 0 ]] ; then
echo -e " ${bullet_mark} alias saved : 'spb' ${tick_mark}"
else
echo " ERROR! : unable to save alias : spb" ; echo ""
echo " fish spb funtion setup aborted." ; echo ""
exit -77
fi
fi
# echo print some helpful information about overiding the spb alias to include desired options ; which should be used with fish snippits
echo ""
echo " If you would like to have custom options passed to spb when using the"
echo " fish snippits, then override the spb alias. An example is provided below:"
echo " alias --save spb \"start-private-browser --window-position=10,10\""
# are we going to install the fish functions - check if there are alrady some and allow user to cancel if any are found
if [[ "${SPB_FISH_FUNCTION_SKIP_OVERWRITE_CHECK}" == "false" ]] ; then
if [[ ${existing_spb_functions_return_code} == 0 ]] ; then
echo ""
echo "Existing spb functions were detected : "
echo ""
fish -c "functions" | grep -E "^spb-" | sed "s/^/$(echo -e ' \xE2\x80\xA2 ')/"
echo ""
echo -n " continue and update/overwrite these existing fish functions? [Y/n] : "
read overwrite_existing
if \
[[ "${overwrite_existing}" == "n" ]] || \
[[ "${overwrite_existing}" == "N" ]] || \
[[ "${overwrite_existing}" == "no" ]] || \
[[ "${overwrite_existing}" == "No" ]] || \
[[ "${overwrite_existing}" == "NO" ]] \
; then
abort_fish_function_setup
fi
fi
else
echo ""
echo " WARNING! : SPB_FISH_FUNCTION_SKIP_OVERWRITE_CHECK = true"
echo " WARNING! : Overwriting existing fish functions"
fi
echo ""
# prevent exit if we hit an error and remove the EXIT trap
set +e
trap - EXIT
# install the various functions (execute the scripts inplace ratherthan coping into place. This should be switched to fisher at some point)
echo " sourcing latest spb fish functions ..."
for current_function_name in $(echo ${functions_to_load} | tr "\n" " " ) ; do
if ! [ -f ./${current_function_name} ] ; then
echo "ERROR! : unable to locate function to load : "
echo " $PWD/${current_function_name}" ; echo ""
echo " fish spb funtion setup aborted." echo ""
exit -3
fi
fish -c "source ./${current_function_name} > /dev/null"
if [[ ${?} == 0 ]] ; then
echo -e " ${bullet_mark} ${current_function_name} ${tick_mark}"
else
echo "ERROR! : unable to load function : ${current_function_name}" ; echo ""
echo " fish spb funtion setup aborted." ; echo ""
exit -77
fi
done
echo -e "\n --- fish functions loaded succesfully --- " ; echo ""
# print some helpful informaiton about finding more information
echo "Uninstall instruction : "
echo ""
echo " uninstall spb fish alias :"
echo " rm -v ~/.config/fish/functions/spb.fish"
echo " rm -v ~/.config/fish/functions/start-private-browser.fish"
echo ""
echo " uninstall spb fish functions : (caution this is using a wild card)"
echo " rm -v ~/.config/fish/functions/spb-*.fish"
echo "" ; echo ""
echo "Documentation and usage instructions for spb fish functions is available from : "
echo "${fish_spb_snippits_gist_link}" ; echo ""
# clean up
cd /tmp/ && rm -rf ${temporary_build_directory}
exit ${?}
# one line command to configure spb-pai functioin to start multiple perplexity ai a chats in multiple private browser tabs.
# this function requires spb (start-private-browser) alias to be configured : https://gist.github.com/henri/34f5452525ddc3727bb66729114ca8b4
# this function requires an alias 'start-private-browser' and 'spb' to be setup eg :
# alias --save start-private-browser="~/bin/start-private-browser.bash"
# alias --save spb="start-private-browser"
# run the following in a fish shell to configure for your shell :
# OLD : function spb-pai ; set urls ( while test (count $argv) -gt 0 ; echo "https://www.perplexity.ai/?q=$argv[1]" | tr " " "+" ; set --erase argv[1] ; end ) ; spb $urls ; end ; funcsave spb-pai
# run the following in a fish shell to configure for your shell :
function spb-pai
set urls (
while test (count $argv) -gt 0
switch $argv[1]
case '--template' '--new-template' '--edit-template' '--force-stop'
echo "$argv[1]"
echo "$argv[2]"
set --erase argv[1]
case '--help' '--list' '-ls' '-l' '--list-templates' '--update'
echo "$argv[1]"
break
case '--standard' '--quite'
echo "$argv[1]"
case '*'
echo (echo "https://www.perplexity.ai/?q=$argv[1]" | tr " " "+")
end
set --erase argv[1]
end
)
spb $urls
end
funcsave spb-pai
# usage example - lets say you want to start five chats in five tabs. Use the command below :
# spb-pai "cats creap" "dogs dance" "mice play" "dear dash" "rabbits rule"
# note : this command offers basic support for special characters. The only subsittion is space characters are turned into plus signs. If you are searching
# for something with odd characters then probably using this script is not a great idea.
# todo : turn this into a fisher package rather than a gist
# one line command which setups up spb as an alias to start-private-browser and passes along the flag to start tor automatically
# this function requires start-private-browser to be configured : https://gist.github.com/henri/34f5452525ddc3727bb66729114ca8b4
# this function requires an alias 'start-private-browser' to be setup eg : alias --save start-private-browser="~/bin/start-private-browser.bash"
# run the following in a fish shell to configure for your shell :
alias -s spb-tor "spb --tor"
# usage example to open private browser and view http://slashdot.org" and "https://xkcd.com/"
# spb-tor "http://slashdot.org" "https://xkcd.com/"
# todo : turn this into a fisher package rather than a gist
# one line command which setups up spb-yt as a command to search YouTube with provided search arguments in a private browser
# this function requires spb (start-private-browser) alias to be configured : https://gist.github.com/henri/34f5452525ddc3727bb66729114ca8b4
# this function requires an alias 'start-private-browser' and 'spb' to be setup eg :
# alias --save start-private-browser="~/bin/start-private-browser.bash"
# alias --save spb="start-private-browser"
# run the following in a fish shell to configure for your shell :
# OLD : function spb-yt ; set urls ( while test (count $argv) -gt 0 ; echo "https://www.youtube.com/results?search_query=$argv[1]" | tr " " "+" ; set --erase argv[1] ; end ) ; spb $urls ; end ; funcsave spb-yt
# run the following in a fish shell to configure for your shell :
function spb-yt
set urls (
while test (count $argv) -gt 0
switch $argv[1]
case '--template' '--new-template' '--edit-template' '--force-stop'
echo "$argv[1]"
echo "$argv[2]"
set --erase argv[1]
case '--help' '--list' '-ls' '-l' '--list-templates' '--update'
echo "$argv[1]"
break
case '--standard' '--quite'
echo "$argv[1]"
case '*'
echo (echo "https://www.youtube.com/results?search_query=$argv[1]" | tr " " "+")
end
set --erase argv[1]
end
)
spb $urls
end
funcsave spb-yt
# usage example to open private browser and search for "hello world" and "this big world" in two YouTube tabs.
# spb-yt "hello world" "this big world"
# note : this command is not complex only space characters are turned into plus signs. If you are searching
# for something with odd characters then probably using this script is not a great idea.
# todo : turn this into a fisher package rather than a gist
##### NOTE THIS SNIPPIT IS NOT INSTALLED BY DEFAULT #####
# spb-fish-function-installer.bash will setup this basic alias. But the idea is that
# you are able to load in a custom spb alias which may include other settings
# for example if you always want spb to use a proxy, just set that up
# using the example below. If you want to spb to always use tor then set it up below.
# one line command which setups up spb as an alias to start-private-browser
# this function requires start-private-browser to be configured : https://gist.github.com/henri/34f5452525ddc3727bb66729114ca8b4
# this function requires an alias 'start-private-browser' to be setup eg : alias --save start-private-browser="~/bin/start-private-browser.bash"
# run the following in a fish shell to configure for your shell :
alias -s spb "start-private-browser"
# usage example to open private browser and view http://slashdot.org" and "https://xkcd.com/"
# spb "http://slashdot.org" "https://xkcd.com/"
# The examples below are some additional alteratives. You may of course mix and match these to meet your needs.
# run the following in a fish shell to configure spb to always use a specific window location
alias -s spb "start-private-browser --window-position=0,0"
# use this to specify a proxy for all spb requests and snippits :
alias -s spb "start-private-browser --proxy-server=http://<hostname:<port>"
# this example will result in all spb sessions using the tor network
alias -s spb "start-private-browser --tor"
# todo : turn this into a fisher package rather than a gist
#////////////////////////////////////////////////////////////////////////
# the line below is added in just in case you source this scipt.
alias -s spb "start-private-browser"
#////////////////////////////////////////////////////////////////////////
# 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