Fred Stluka on 20 Dec 2018 10:01:51 -0800 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] bash cheat sheet |
On 12/18/18 11:26 AM, jeff wrote:
https://snapcraft.io/cheat
I've always just created aliases for command/option combinations I use often. Can display them by typing the first couple chars and hitting tab. Can see them all by typing the alias command w/no args. And since I define them in my startup file, I can document them there too. Has served me well for 30+ years of Unix/Linux use. For example: alias since 'find . -ctime -\!* -ls'# Recursive directory search for files # modified since specified number of days
And for the most useful Git commands: alias got git # Frequent typoalias gitls git ls-files # List files in Git # Example: gitls foo.c # Example: gitls *.c # (May need gitls \*.c to avoid # shell globbing?) # Made into a script to use from other scripts: # alias gitpulldryrun git fetch --dry-run -v# Use fetch. There's no pull --dry-run
alias gitfetchdryrun git fetch --dry-run -v # Show if there's anything to pull alias gitdiffremote git diff master origin/master# Show details of what would be pulled
# Doesn't work. Why not? alias gitsync ./gitsync alias gits git status alias gitunstage git reset HEAD # Unstage w/o changing working copy alias gitdiff git diff HEAD # Staged and unstaged diffs alias gitdiffmaster git diff master.. # Diffs from master branch alias gitdifffilenames git diff --name-only # Names of files with diffsalias gitaddinteractive git add -i # Git shell for status, diff, add, etc. alias gitaddpatch git add -p # Stage portion of a file to be committed
alias gitwhatfileschanged git whatchanged # Show all files in a commit alias gitlogshowchanges git log -p alias gitwhatlineschanged git log -p # Show diffs of files in commit log alias gitlog git log --graph alias gitlogsincereverse 'git log --since=\!:1 --reverse -- \!:2' # p1 = When in log to start # Example: two.weeks.ago # p2 = File to show log for alias gitblameperline git blame alias gitshow git show # Example: gitshow SomeBranch:foo.c alias gitlogstatsummary git log --stat --summary alias gitlogoneline git log --oneline # One line per commit alias gitloggroupbyperson git shortlog # Commits grouped by committer# Example: gitloggroupbyperson -s -n
alias gitlogofperson 'git log --author=\!:1' alias gitlogbeforeafter 'git log --before=\!:1 --after=\!:2' alias gitloglinerange 'git log -L \!:1,\!:2' # Example: gitloglinerange 1 5 foo.c alias gitlogmethodchanged 'git log -L:\!:1:\!:2'# Example: gitlogmethodchanged bar foo.c
alias gitgui git gui alias gitk gitk alias gitx gitxalias gitcheckout git checkout # Example: gitcheckout SomeBranch foo.c
# Example: gitcheckout SomeHash foo.calias gitcommit git commit -v # Show diffs in editor for Git comments
alias gitcommitamend git commit --amend alias gitgrep git grep -i --heading --line-number alias gitcherrypick git cherry-pick --signoff -x# Get files from a specified old commit # and create a new commit on the current
# branch# --signoff = Add my name to the commit
# comment# -x = Add "(cherry picked from # commit ...)" to the commit
# comment alias gitcherrypicknonewcommit git cherry-pick --no-commit# Get files from a specified old commit
# but do not create a new commit alias gitstashlist git stash list alias gitstash git stash alias gitstashapply git stash apply alias gitstashapplystage git stash apply --index alias gitstashdrop git stash drop alias gitstashpush git stash alias gitstashpop git stash pop alias gitstashdiff git stash show -p alias gitstashpoptobranch git stash branch alias gitdifffast git diff --no-ext-diff # (Bypass external diff tool) alias gitremote git remote -v # Show full URLS also alias gitbranch 'git status -b --porcelain | head -1 | cut -c 4-' # Show current branch alias gitb gitbranch alias gitbranches git branch -a -v # Show all branches alias gitbranchswitch git checkout alias gitbranchcreate git branch alias gitbranchcreateandswitch git checkout -b alias gitbranchdelete git branch -d alias gitbranchmerge 'git checkout master; git merge' alias gitbranchpush git push origin # No. Defaults to doing the pull even w/o the --track option # alias gitbranchpull 'git checkout --track origin/\!:1' alias gitbranchpull git checkout alias gitbranchchanges git log master.. # See ~/fred/git/Tips/branchlog.txt alias gitm git checkout master alias gitcf git checkout merged_from_cf_replacement alias reviewcf 'delete_pyc_files; windiff . $PWD.cf_reviewed' alias gitmergeresolve git add alias githelp git help # Help on Git commands alias gitbisectstart git bisect start alias gitbisectbad git bisect bad alias gitbisectgood git bisect good alias gitbisectreset git bisect reset alias gitbisectrun 'git bisect start HEAD \!:1 run \!:2' # p1 = bad_hash # p2 = script to build and run # regression tests For more, see: - http://bristle.com/Tips/Unix.htm#csh_sample_cshrc_file --Fred ------------------------------------------------------------------------ Fred Stluka -- Bristle Software, Inc. -- http://bristle.com #DontBeATrump -- Make America Honorable Again! ------------------------------------------------------------------------ ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug