Skip to content

Commit

Permalink
Change the way fish history is kept across restart
Browse files Browse the repository at this point in the history
  • Loading branch information
hanoii committed Apr 12, 2024
1 parent 7a022fa commit f6bd8b0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .ddev/addon-metadata/pimp-my-shell/manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: pimp-my-shell
repository: .
version: ""
install_date: "2024-04-10T11:42:39-03:00"
install_date: "2024-04-12T12:12:39-03:00"
project_files:
- web-build/Dockerfile.pimp-my-shell
- homeadditions/.bashrc.d/pimp-my-shell.sh
Expand Down
12 changes: 9 additions & 3 deletions .ddev/homeadditions/.config/fish/conf.d/pimp-my-shell.fish
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ lua /opt/z.lua/z.lua --init fish | source
# fish
mkdir -p /mnt/ddev-global-cache/fishhistory/$HOSTNAME
# workaround to keep the history file accross restarts
[ -f ~/.local/share/fish/fish_history ] && [ ! -L ~/.local/share/fish/fish_history ] && mv ~/.local/share/fish/fish_history /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history
[ ! -f ~/.local/share/fish/fish_history ] && touch /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history
ln -fs /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history ~/.local/share/fish/fish_history
# https://fishshell.com/docs/current/cmds/history.html#customizing-the-name-of-the-history-file
# I am not using $XDG_DATA_HOME as that would change a lot of things, I rather
# just keep things default and do this cp workaround.
function handler --on-event fish_postexec
cp ~/.local/share/fish/fish_history /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history
end
if test -f /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history
cp /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history ~/.local/share/fish/fish_history
end

function fish_title
echo "$DDEV_PROJECT ddev@"(fish_prompt_pwd_dir_length=1 prompt_pwd) - $argv
Expand Down
12 changes: 9 additions & 3 deletions homeadditions/.config/fish/conf.d/pimp-my-shell.fish
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ lua /opt/z.lua/z.lua --init fish | source
# fish
mkdir -p /mnt/ddev-global-cache/fishhistory/$HOSTNAME
# workaround to keep the history file accross restarts
[ -f ~/.local/share/fish/fish_history ] && [ ! -L ~/.local/share/fish/fish_history ] && mv ~/.local/share/fish/fish_history /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history
[ ! -f ~/.local/share/fish/fish_history ] && touch /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history
ln -fs /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history ~/.local/share/fish/fish_history
# https://fishshell.com/docs/current/cmds/history.html#customizing-the-name-of-the-history-file
# I am not using $XDG_DATA_HOME as that would change a lot of things, I rather
# just keep things default and do this cp workaround.
function handler --on-event fish_postexec
cp ~/.local/share/fish/fish_history /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history
end
if test -f /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history
cp /mnt/ddev-global-cache/fishhistory/$HOSTNAME/fish_history ~/.local/share/fish/fish_history
end

function fish_title
echo "$DDEV_PROJECT ddev@"(fish_prompt_pwd_dir_length=1 prompt_pwd) - $argv
Expand Down

0 comments on commit f6bd8b0

Please sign in to comment.