Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jan 28 22:21
    verdie-g opened #893
  • Jan 28 10:19
    VonUniGE commented #340
  • Jan 28 02:20
    rcywongaa closed #869
  • Jan 26 20:30
    smkniazi edited #892
  • Jan 26 20:29
    smkniazi edited #892
  • Jan 26 20:28
    smkniazi opened #892
  • Jan 24 10:38
    timotheecour edited #890
  • Jan 24 09:20
    timotheecour opened #891
  • Jan 24 00:29
    timotheecour opened #890
  • Jan 23 22:09
    KeeReal commented #869
  • Jan 23 20:58
    avivey opened #889
  • Jan 21 23:26
    timotheecour commented #559
  • Jan 21 21:16
    koutcher commented #559
  • Jan 21 20:47
    koutcher commented #559
  • Jan 21 18:39
    smancill commented #559
  • Jan 21 07:11
    timotheecour commented #559
  • Jan 20 17:01
    smancill commented #559
  • Jan 20 10:25
    koutcher commented #559
  • Jan 20 02:54
    timotheecour commented #559
  • Jan 20 01:56
    timotheecour opened #888
Hsieh Chin Fan
bind generic xf +sh -c "echo -n %(file) | xclip -sel c && echo File Clipped"
Hsieh Chin Fan
I have code above in my .tigrc, press xf will copy file in current line into clipboard, and echo "File Clipped" in status bar.
Be aware the way woks with clipboard differs by OS. In this case, I use xclip in binding(Ubuntu) .
You should make your own based on your machine, go through docs for tigrc really helps.
Hsieh Chin Fan
Or just use tig built-in command, type :edit or press e can open current file in editor , see
Mikhail Mirzoyan
@typebrook thanks a lot! Works out of the box in my Ubuntu as well :)
Wish i had time for all the docs
i've seen :edit but it doesn't work for me as i want the file to be opened in my already opened vim session, not in a new one
Sebastian Gniazdowski
Why there's no binding for git push? How to add one?
Why the binding doesn't work?
bind generic xf +sh -c "cat %(file) | pbcopy && echo File Copied Into The Cliboard (paste with Cmd-V)"
Sebastian Gniazdowski
I've managed to add the binding for push. So what's left is only the above xf-binding that doesn't yield anything in the clipboard, and ends with "No output"
Hsieh Chin Fan
pbcopy is here so I guess you use mac. And here you want to store file content into clipboard.
Try to use command directly before set it as key binding, so you can try:
:!cat %(file)
to test it print file content correctly
Sebastian Gniazdowski
@typebrook It's a funny thing because :!cat %(file) | pbcopy opens a pager
like if the redirection, the pipe was ignored and pbcopy not feed with the input
Ok, I've got it – it was the paren, it has to be quoted (syntax error otherwise)
Nitesh kumar
Mikhail Mirzoyan
is there an (easy) way to stash some changes from different files one by one but under the same stash?
Hsieh Chin Fan
There is an useful command you can put in .gitconfig as alias
    stashstaged = !git stash --keep-index && \
                   git stash && \
                   git stash apply stash@{1} && \
                   git stash show -p | git apply -R && \
                   git stash drop stash@{1}
Literally, it just stash changes in staged area, so you can:
  1. only stage the changes/hunk you want to put into stash
  2. call :!git stashstaged
Sorin Sbarnea
i really want to stop using gui git clients and replace them with a tui tool but someone I fail to figure out how to perform basic operations with tig, like commit current changes as new commit, ammend, pull, push. Someone the introduction documentation does not cover stuff line this.
Hsieh Chin Fan

Nope, the default configuration doesn't cover those commands. (Check https://github.com/jonas/tig/blob/master/tigrc or just press h to enter help view)
But since tig is just a pager for git commands, what make it powerful is you can bind your own commands/scripts with keys in different view.s

Here is my own .tigrc, nearly make me perform all frequently-used git commands in few seconds. For example:
c to commit with only title (in status view)
Cto have a full commit (in status view)
a to amend previous commit (in main and status view)
F to fetch current branch (in main view)
C-F to fetch remote in current line (in main view)
pp to directory push to remote of current branch
pP to force push
pr to push a given remote
pd to delete remote branch

Take a look and you'll find .tigrc is self-explained and so easy to configure. (Also, don't forget to read man tigrc)

Hsieh Chin Fan
And of course, you can always perform command at bottom line with decorator :
       !   Run the command in the foreground with
           output shown.

       @   Run the command in the background with no

       +   Run the command synchronously, and echo the
           first line of output to the status bar.

       ?   Prompt the user before executing the

      >  For a new tig instance

       <   Exit Tig after executing the command.
Sorin Sbarnea
thanks for the update. Still there is a serious issue with the approach of "do everything via git". It makes the tool less portable because everyone would have to sync the tool configuration to a never ending list of machines. Also means that if I step in on someone else terminal to help with something i will be guaranteed to miss my custom aliases.
that is why I value a tool that does not need customization, so I can just install it and ripe the benefits.
(basic operations, i do not expect to implement everything). there is a lot of value in aliases.
Hsieh Chin Fan
If you think the tig's default key-bindings is not enough, then I'll suggest lazygit
Sorin Sbarnea
Thanks for the hint, at least on paper it looks like what I was looking for. Sadly, first command caused jesseduffield/lazygit#501
Sebastian Gniazdowski
Can you somehow send a command to tig through e.g. a file? I want to change the current directory from the outside of tig