Skip to content

Instantly share code, notes, and snippets.

@abdumu
Created July 5, 2023 22:41
Show Gist options
  • Save abdumu/8780da90980e098f7d28911c8395db07 to your computer and use it in GitHub Desktop.
Save abdumu/8780da90980e098f7d28911c8395db07 to your computer and use it in GitHub Desktop.
random quote in your terminal as welcome message from thousands of quotes, using php with fish
# 1 - you should install php in your system (apt-get install php)
# 2 - download (https://github.com/mubaris/motivate/blob/master/motivate/data_unique/unique_quotes.json)
# 3 - place unique_quotes.json in ~/.config/fish
# 4 - add the code below in your ~/.config/fish/config.fish
# 5 - enjoy.
function fish_greeting
php -r 'echo (function () { $a = json_decode(file_get_contents(\'/'$HOME'/.config/fish/unique_quotes.json\'), true)[\'data\']; $k = array_rand($a); return $a[$k][\'quote\']."\\n— ".$a[$k][\'author\']."\\n";})();';
end
@abdumu
Copy link
Author

abdumu commented Jul 5, 2023

if you wanna add it to bash, just add this to your ~/.bashrc

php -r 'echo (function ()  { $a = json_decode(file_get_contents(\'/'$HOME'/.config/fish/unique_quotes.json\'), true)[\'data\']; $k = array_rand($a); return $a[$k][\'quote\']."\\n— ".$a[$k][\'author\']."\\n";})();';

@abdumu
Copy link
Author

abdumu commented Jul 5, 2023

Also this work for zsh I think, add to your ~/.zshrc.

php -r 'echo (function ()  { $a = json_decode(file_get_contents(\'/'$HOME'/.config/fish/unique_quotes.json\'), true)[\'data\']; $k = array_rand($a); return $a[$k][\'quote\']."\\n— ".$a[$k][\'author\']."\\n";})();';

@abdumu
Copy link
Author

abdumu commented Jul 5, 2023

I didnt try the bash/zsh versions, so try and tell me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment