behavior of git branch in powerlevel10k - oh-my-zsh

I am using oh-my-zsh and powerlevel10k on Mac and I observed a weird behavior when using git branch. Instead of like other commands, like git status which will list the result in current terminal.
However, git branch is like into an editor mode and I have to press q to exit the mode to get back to terminal.
Anyone knows how to fix it, i.e., let the git branch command to show results in current terminal instead of entering into an editor mode?

It seems that since version 2.16, git defaults to use the pagination for the branch command.
You can disable pagination for branch command only using
git config --global pager.branch false
It seems to be working for your specific shell

git is using the pager (usually less command) for its output.
you can configure it via core.pager for all the git commands or use per command config pager.<cmd>; there is also GIT_PAGER env variable
the easiest way to skip the paging for one time is to use --no-pager option for command; and to disable the paging completely git documentation suggests:
To disable pagination for all commands, set core.pager or GIT_PAGER to cat.
git config --global core.pager cat
you may experiment with setting the pager to less -F -X; this will make less command to page the content only if it does not fit the screen -F, and not to clean the terminal buffer -X
git config --global core.pager 'less -F -X'
or simply disable the pager for the branch command
git config --global pager.branch false

Related

How to enable and disable yum repos using the command line

I'm attempting to edit the yum.repos.d file in order to disable unwanted repos and enable wanted repos without using the vi editor. Each time I use the method I know of it fails to make the changes. Does anyone know what I'm missing?
See Below:
yum-config-manager --disable \therepoid,anotherrepoid
Note: I'm not executing this from the yum.repos.d directory
First you need to run the command as root
Then you should get the list of repos:
yum repolist all
And then you can enable or disable particular repo(s) by repo_id from previous command
yum-config-manager --enable repo_id
For reference you can use RedHat documentation

"docker run -dti" with a dumb terminal

updated: added the missing docker attach.
Hi am trying to run a docker container, with -dti. but I cannot access with a terminal set to dumb. is there a way to change this (it is currently set to xterm, even though my ssh client is dumb)
example:
create the container
docker run -dti --name test -v /my-folder alpine /bin/ash
docker attach test
apk --update add nodejs
cd /my-folder
npm install -g gulp
the last command always contains ascii escape chars to move the cursor.
I have tried "export TERM=dumb" inside the running container, but it does not work.
is there a way to "run" this using the dumb terminal?
I am running this from a script on another computer, via (dumb) ssh.
using the -t which sets this https://docs.docker.com/engine/reference/run/#env-environment-variables, however removing effects the command prompt (the prompt is not shown)
possible solution 1 remove the -t and keep the -i. To see if the command has completed echo out a known token (ENDENDEND). ie
docker run -di --name test -v /my-folder alpine /bin/ash
docker attach test
apk --update add nodejs;echo ENDENDEND
cd /my-folder;echo ENDENDEND
npm install -g gulp;echo ENDENDEND
not pretty, but it works (there is no ascii in the results)
Possible solution 2 use the journal, docker can log out to the linux journal, this can be gathered as commands are executed in the container. (I have yet to fully test this one out. however the log seems to be a nicer output of what happened)
update:
Yep -t is the problem.
However if you want to see the entire process when running a command, maybe this way is better:
docker run -di --name test -v/my-folder alpine /bin/ash
docker exec -it test /bin/ash
finally you need to kill the container after all jobs finished.
docker run -d means "Run container in background and print container ID"
not start the container as a daemon
I was hitting this issue on OSx running docker, i had to do 2 things to stop the terminal/ascii/ansi escape sequences.
remove the "t" option on the docker run command (from docker run -it ... to docker run -i...)
ensure to force bash or sh shells used on osx when running the command from a script file, not the default zsh
Also
the escape sequences were not always visible on the terminal
even so, they still usually caused content corruption, even with SED brought to bear
they always were shown in my editor

Subversion export/checkout in Dockerfile without printing the password on screen

I want to write a Dockerfile which exports a directory from a remote Subversion repository into the build context so I can work with these files in subsequent commands. The repository is secured with user/password authentication.
That Dockerfile could look like this:
# base image
FROM ubuntu
# install subversion client
RUN apt-get -y update && apt-get install -y subversion
# export my repository
RUN svn export --username=myUserName --password=myPassword http://subversion.myserver.com/path/to/directory
# further commands, e.g. on container start run a file just downloaded from the repository
CMD ["/bin/bash", "path/to/file.sh"]
However, this has the drawback of printing my username and password on the screen or any logfile where the stdout is directed, as in Step 2 : RUN svn export --username=myUserName --password=myPassword http://subversion.myserver.com/path/to/directory. In my case, this is a Jenkins build log which is also accessible by other people who are not supposed to see the credentials.
What would be the easiest way to hide the echo of username and password in the output?
Until now, I have not found any way how to execute RUN commands in a Dockerfile silently when building the image. Could the password maybe be imported from somewhere else and attached to the command beforehand so it does not have to be printed anymore? Or are there any methods for password-less authentication in Subversion that would work in the Dockerfile context (in terms of setting them up without interaction)?
The Subversion Server is running remotely in my company and not on my local machine or the Docker host. To my knowledge, I have no access to it except for accessing my repository via username/password authentication, so copying any key files as root to some server folders might be difficult.
The Dockerfile RUN command is always executed and cached when the docker image is build so the variables that svn needs to authenticate must be provided at build time. You can move the svn export call when the docker run is executed in order to avoid this kind of problems. In order to do that you can create a bash script and declare it as a docker entrypoint and pass environment variables for username and password. Example
# base image
FROM ubuntu
ENV REPOSITORY_URL http://subversion.myserver.com/path/to/directory
# install subversion client
RUN apt-get -y update && apt-get install -y subversion
# make it executable before you add it here otherwise docker will coplain
ADD docker-entrypoint.sh /enrypoint.sh
ENTRYPOINT /entrypoint.sh
docker-entrypoint.sh
#!/bin/bash
# maybe here some validation that variables $REPO_USER $REPO_PASSOWRD exists.
svn export --username="$REMOTE_USER" --password="$REMOTE_PASSWORD" "$REPOSITORY_URL"
# continue execution
path/to/file.sh
Run your image:
docker run -e REPO_USER=jane -e REPO_PASSWORD=secret your/image
Or you can put the variables in a file:
.svn-credentials
REPO_USER=jane
REPO_PASSWORD=secret
Then run:
docker run --env-file .svn-credentials your/image
Remove the .svn-credentials file when your done.
Maybe using SVN with SSH is a solution for you? You could generate a public/private key pair. The private key could be added to the image whereas the public key gets added to the server.
For more details you could have a look at this stackoverflow question.
One solution is to ADD the entire SVN directory you previously checked out on your builder file-system (or added as a svn:externals if your Dockerfile is itself in a SVN repository like this: svn propset svn:externals 'external_svn_directory http://subversion.myserver.com/path/to/directory' ., then do a svn up).
Then in your Dockerfile you can simply have this:
ADD external_svn_directory /tmp/external_svn_directory
RUN svn export /tmp/external_svn_directory /path/where/to/export/to
RUN rm -rf /tmp/external_svn_directory
Subversion stores authentication details (if it not disabled in configuration) at client side and use stored username|password on request for the subsequent operations on the same URL.
Thus - you have to run (successful) svn export in Dockerfile with username|password only once and allow SVN to use cached credentials (remove auth. options from command-line) later

Enabling git log parameters by default

I like the way that the following command prints out git logs:
git log --oneline --decorate --graph
I would like to make that the default format whenever I use git log. Is there a way to edit ~/.gitconfig to enable oneline, decorate, and graph by default?
And yes, I'm aware that I can alias those options to another git command alias, but I'd rather that log just print out using those options by default.
Git allows you to activate --oneline and --decorate by default for log, show, etc.:
git config --global format.pretty oneline
git config --global log.decorate short
However, as of v2.1.0 v2.2.2, Git does not allow you to activate --graph by default. One way around that (adapted from this SuperUser answer) is to define the following function in your .<shell>rc file:
git() {
if [ "$1" = "log" ]
then
command git log --graph "${#:2}";
else
command git "$#";
fi;
}
One caveat (pointed out by hvd in his comment): if you specify options between git and log, as in
git -c log.showroot=false log -p
then, because the first argument is -c and not log, the --oneline --decorate --graph flags won't be used.

How To Upload Files on GitHub

I have recently downloaded GitHub and created a repository on it. I am trying to upload an Objective C project in it. How do I go about doing this?
I didn't find the above answers sufficiently explicit, and it took me some time to figure it out for myself. The most useful page I found was:
http://www.lockergnome.com/web/2011/12/13/how-to-use-github-to-contribute-to-open-source-projects/
I'm on a Unix box, using the command line. I expect this will all work on a Mac command line. (Mac or Window GUI looks to be available at desktop.github.com but I haven't tested this, and don't know how transferable this will be to the GUI.)
Step 1: Create a Github account
Step 2: Create a new repository, typically with a README and LICENCE file created in the process.
Step 3: Install "git" software.
(Links in answers above and online help at github should suffice to do these steps, so I don't provide detailed instructions.)
Step 4: Tell git who you are:
git config --global user.name "<NAME>"
git config --global user.email "<email>"
I think the e-mail must be one of the addresses you have associated with the github account. I used the same name as I used in github, but I think (not sure) that this is not required. Optionally you can add caching of credentials, so you don't need to type in your github account name and password so often. https://help.github.com/articles/caching-your-github-password-in-git/
Create and navigate to some top level working directory:
mkdir <working>
cd <working>
Import the nearly empty repository from github:
git clone https://github.com/<user>/<repository>
This might ask for credentials (if github repository is not 'public'.)
Move to directory, and see what we've done:
cd <repository>
ls -a
git remote -v
(The 'ls' and 'git remote' commands are optional, they just show you stuff)
Copy the 10000 files and millions of lines of code that you want to put in the repository:
cp -R <path>/src .
git status -s
(assuming everything you want is under a directory named "src".) (The second command again is optional and just shows you stuff)
Add all the files you just copied to git, and optionally admire the the results:
git add src
git status -s
Commit all the changes:
git commit -m "<commit comment>"
Push the changes
git push origin master
"Origin" is an alias for your github repository which was automatically set up by the "git clone" command. "master" is the branch you are pushing to. Go look at github in your browser and you should see all the files have been added.
Optionally remove the directory you did all this in, to reclaim disk space:
cd ..
rm -r <working>
Well, there really is a lot to this. I'm assuming you have an account on http://github.com/. If not, go get one.
After that, you really can just follow their guide, its very simple and easy and the explanation is much more clear than mine: http://help.github.com/ >> http://help.github.com/mac-set-up-git/
To answer your specific question: You upload files to github through the git push command after you have added your files you needed through git add 'files' and commmited them git commit -m "my commit messsage"
You need to create a git repo locally, add your project files to that repo, commit them to the local repo, and then sync that repo to your repo on github. You can find good instructions on how to do the latter bit on github, and the former should be easy to do with the software you've downloaded.
To upload files to your repo without using the command-line, simply type this after your repository name in the browser:
https://github.com/yourname/yourrepositoryname/upload/master
and then drag and drop your files.(provided you are on github and the repository has been created beforehand)
Here are the steps (in-short), since I don't know what exactly you have done:
1. Download and install Git on your system: http://git-scm.com/downloads
2. Using the Git Bash (a command prompt for Git) or your system's native command prompt, set up a local git repository.
3. Use the same console to checkout, commit, push, etc. the files on the Git.
Hope this helps to those who come searching here.
if you're on windows:
http://windows.github.com/
otherwise:
http://git-scm.com/downloads/guis
If you want to upload a folder or a file to Github
1- Create a repository on the Github
2- make: git remote add origin "Your Link" as it is described on the Github
3- Then use git push -u origin master.
4- You have to enter your username and Password.
5- After the authentication, the transfer will start