config.fish

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

config.fish

Unread post by GekkoP » Sun Mar 12, 2017 3:53 pm

I've been using/testing the Fish shell in the last couple of days.

My setup is here: https://github.com/manuel-uberti/dotfil ... onfig/fish

And for the Emacs lovers out there:

Code: Select all

(use-package fish-mode                  ; Handle Fish shell scripts
  :ensure t
  :mode ("\\.fish\\'" . fish-mode)
  :config
  ;; Run fish_indent before save
  (add-hook 'fish-mode-hook
            (lambda ()
              (add-hook 'before-save-hook 'fish_indent-before-save))))
Let's see if Fish can move me away from Zsh for a while.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: config.fish

Unread post by GekkoP » Wed Mar 15, 2017 9:50 pm

So far so good. I particularly like the clean syntax for custom functions.

For instance:

Code: Select all

function get -d 'Download from a remote URL'
    if command --search 'curl' >/dev/null
        curl --continue-at - --location --progress-bar --remote-name --remote-time $argv
    else if command --search 'wget' >/dev/null
        wget --continue --progress=bar --timestamping $argv
    else
        echo 'Don\'t know how to download'
        return 1
    end
end

User avatar
akts
apt-getter
Posts: 76
Joined: Mon Sep 30, 2013 3:51 am
Location: /dev/null
Contact:

Re: config.fish

Unread post by akts » Sun Mar 19, 2017 1:42 pm

Fish ootb experience is pretty snazzy. It's almost like zsh + oh-my-zsh in a single package.

Thanks for the sauce GekkoP :)
Everything is funny, as long as it's happening to somebody else. -- Will Rogers

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: config.fish

Unread post by GekkoP » Sun Mar 19, 2017 2:45 pm

^ Yes, it feels like a bloated zsh at first (which in turn feels like a bloated bash, which it's a bloated...). But it won me over with its completion and its syntax. :)

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: config.fish

Unread post by GekkoP » Fri Nov 24, 2017 4:47 pm

New release of Fish added SSH hosts completion among other things. I also added z (instead of autojump) and docker-completion via fisherman.

Rock solid experience.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: config.fish

Unread post by wuxmedia » Mon Nov 27, 2017 9:35 am

"hosts completion" how can it know...? does it check your .ssh/config or the known hosts?
That's the only thing I would like, with having potentially a metric fuckton of hosts to attach to.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: config.fish

Unread post by GekkoP » Mon Nov 27, 2017 1:10 pm

It checks .ssh/config.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: config.fish

Unread post by wuxmedia » Fri Dec 01, 2017 10:12 am

uh missed this. right, turns out bash can do the same thing which is quite handy.
Hmm, or the shell can read the entries in know_hosts, which is a slightly more sensible approach.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: config.fish

Unread post by GekkoP » Fri Dec 01, 2017 11:14 am

Oh yes, bash and zsh can do that too. But you know me, I fancy hip shells.

User avatar
Baconator
Troll
Posts: 3
Joined: Sat Jun 10, 2017 6:01 am
Location: My IP address will tell you.

Re: config.fish

Unread post by Baconator » Sat Dec 02, 2017 6:00 am

Why not just bash?

It's all you need.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: config.fish

Unread post by GekkoP » Sat Dec 02, 2017 11:36 am

^ Because, as stated above, I fancy hip shells indeed.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: config.fish

Unread post by wuxmedia » Sat Dec 02, 2017 2:46 pm

Honestly I only use bash because ALL the machines I SSH into only ever have bash.
For me using anything would be utterly pointless, I don't even have any clever aliases (although I have started realising I can sneak them into root's .bashrc.
But if you are devving on ones own machine and pushing code to servers - who cares?
Again for me learning/using emacs is a waste of time for 98% of my shell time (although there is someone who keeps trying to use emacs on machines sometimes, when I'm poking about in the bash history)
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: config.fish

Unread post by GekkoP » Sat Dec 02, 2017 3:19 pm

Well, as always YMMV.

I couldn't live without Emacs, it's always there for coding and writing. Thus, Eshell and shell-mode are there too, and Dired for file management is pretty much the only file manager I use these days when not on a terminal. Even SSH for just file editing happens inside Emacs, in my case.

When I am on a terminal, I use ssh only for my home server (which runs fish) and work servers (which run zsh).

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: config.fish

Unread post by wuxmedia » Sat Dec 02, 2017 5:02 pm

shell hipster wrote:work servers (which run zsh)
Interesting - we (at work) are all too old school here to run anything like that.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: config.fish

Unread post by GekkoP » Sat Dec 02, 2017 5:25 pm

^ The man in charge of those machines is a huge oh-my-zsh fanboy. Most of the times, I do an ssh tunnel to a specific port to access the database instance easily.

pidsley
Hermit
Posts: 2539
Joined: Wed Oct 17, 2012 12:31 pm

Re: config.fish

Unread post by pidsley » Sun Dec 03, 2017 2:43 pm

^ I can't count the number of support threads on the Arch forum that have been tracked to problems with oh-my-zsh.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: config.fish

Unread post by wuxmedia » Sun Dec 03, 2017 3:00 pm

^^ yeah - architect's choice I suppose, I doubt I'd even notice if it was fish or zsh - unless there is a special PS1 or I had a script which wouldn't work.
now Mosh, that is awesomely useful.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: config.fish

Unread post by franksinistra » Mon Dec 18, 2017 1:30 pm

Wux wrote: Mosh, that is awesomely useful.
I can't remember how many times have this specific tool saved my life (and my job). Not counting how many times it also saved me from spotty network connection, and other third world problems. 8)
rice no more.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: config.fish

Unread post by wuxmedia » Mon Dec 18, 2017 9:43 pm

damn Mod wandering off topic :D
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: config.fish

Unread post by GekkoP » Fri Jul 20, 2018 2:54 pm

Code: Select all

function tarc -d 'Create archive using pigz'
    set PV (which pv)
    if test -n "$PV"
        echo $argv | read -l archive paths
        echo $paths | read -a paths
        set size (math (du -sb $paths | awk '{print $1}' | paste -sd "+" -))
        tar cfP - $paths | pv -s $size | pigz >$archive
    else
        echo "Please install pv!"
    end
end
Courtesy of Bodil Stokke.

This uses pigz to parallelize the compression process. Useful for huge archives.
Pigz compresses using threads to make use of multiple
processors and cores. The input is broken up into 128 KB
chunks with each compressed in parallel. The individual
check value for each chunk is also calculated in parallel.
The compressed data is written in order to the output, and a
combined check value is calculated from the individual check
values.

Post Reply