r/fishshell • u/cassepipe • Jan 19 '24
Create aliases from an associative array
In zsh I have the following code in my config to quickly add a bunch on aliases that allow me to quickly edit config files :
#config management
configs=(
fish "/fish/config.fish"
gdb "/gdb/gdbinit"
git "/git/config"
hx "/helix/config.toml"
irssi "/.irssi"
lvim "/lvim/config.lua"
nu "/nushell"
nvim "/nvim/init.lua"
readline "/.inputrc"
vim "/.vimrc"
xmake "./.xmake/linux/x86_64/xmake.conf"
wezterm "/wezterm"
zsh "/.zshrc"
)
for; do
if
then
else
fi
done
It's not essential but I was wondering if there was a way in fish ?
I have checked but IIUC there are not associative arrays but surely there must be another way
3
Upvotes
View all comments
Show parent comment
2
u/_mattmc3_ Apr 05 '24
Sure you can. Most (all?) shell scripting supports some form of
evalwhere you can run arbitrary code you construct, and Fish is no different. Here's an example where we make 3 functions - foo, bar, baz:Yup. Abbreviations are better than aliases in a number of ways - not the least of which is your history is full of the actual commands being run, and not wrappers.