Sponsored Content
Full Discussion: Color coding breaks ls?
Top Forums Shell Programming and Scripting Color coding breaks ls? Post 302983853 by GreatBigBore on Tuesday 18th of October 2016 01:16:05 AM
Old 10-18-2016
Color coding breaks ls?

I found a script that almost takes care of a bit of clunkiness in git. I say almost, because when I use it, after it does what it's supposed to do, it breaks my shell, or something. After I use it, I can't use wildcards any more. I tried to run `jshint *.js` as I do a million times a day, but it says it can't find any such files. `ls` does the same thing. I can do `ls` by itself, and everything is there, but `ls *.js` or `ls *` just says the files aren't there. I tried googling, but to tell the truth, I don't have a clear idea of what to google for. "bash script breaks ls" didn't turn up anything useful. Can anyone tell me what is wrong with it?

Code:
green=`tput setaf 2`
reset=`tput sgr0`

git-branch-list() {
  set -f
  git branch | while read line; do
    current="  "
    name=${line##\* }   ## removes leading * for current

    if [ ! "$name" = "$line" ]; then
      current="${green}* "
    fi

    description=`git config branch.$name.description`

    if [ "$description" != "" ]; then
      description=" : $description"
    fi

    echo "${reset}${current}${name}${description}${reset}"
  done
}

 

3 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Why can some servers do color-coding?

What is it that allows emacs (terminal-based) on one server to serve up color-coding while on another server it only comes up black & white? (1 Reply)
Discussion started by: jjinno
1 Replies

2. UNIX for Dummies Questions & Answers

How to change the background color in the init 3 mode(not line color)

Hello, I am using RHEL 6.1 on VMware I am searching for a way to change background color (not line by line color wich one can using tput command) basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)
Discussion started by: Dexobox
2 Replies

3. UNIX for Dummies Questions & Answers

Page breaks and line breaks

Hi All, Need an urgent solution to an issue . We have created a ksh file or shell script which generates 1 DAT file. the DAT file contains extract of a select statement . Now the issue is , when we are executing the ksh file , the output is coimng with page breaks and line breaks . We have... (4 Replies)
Discussion started by: Ayaskant
4 Replies
STG-BRANCH(1)							   StGit Manual 						     STG-BRANCH(1)

NAME
stg-branch - Branch operations: switch, list, create, rename, delete, ... SYNOPSIS
stg branch stg branch <branch> stg branch --list stg branch --create <new-branch> [<committish>] stg branch --clone [<new-branch>] stg branch --rename <old-name> <new-name> stg branch --protect [<branch>] stg branch --unprotect [<branch>] stg branch --delete [--force] <branch> stg branch --description=<description> [<branch>] DESCRIPTION
Create, clone, switch between, rename, or delete development branches within a git repository. stg branch Display the name of the current branch. stg branch <branch> Switch to the given branch. OPTIONS
-l, --list List each branch in the current repository, followed by its branch description (if any). The current branch is prefixed with >. Branches that have been initialized for StGit (with linkstg:init[]) are prefixed with s. Protected branches are prefixed with p. -c, --create Create (and switch to) a new branch. The new branch is already initialized as an StGit patch stack, so you do not have to run linkstg:init[] manually. If you give a committish argument, the new branch is based there; otherwise, it is based at the current HEAD. StGit will try to detect the branch off of which the new branch is forked, as well as the remote repository from which that parent branch is taken (if any), so that running linkstg:pull[] will automatically pull new commits from the correct branch. It will warn if it cannot guess the parent branch (e.g. if you do not specify a branch name as committish). --clone Clone the current branch, under the name <new-branch> if specified, or using the current branch's name plus a timestamp. The description of the new branch is set to tell it is a clone of the current branch. The parent information of the new branch is copied from the current branch. -r, --rename Rename an existing branch. -p, --protect Prevent StGit from modifying a branch -- either the current one, or one named on the command line. -u, --unprotect Allow StGit to modify a branch -- either the current one, or one named on the command line. This undoes the effect of an earlier stg branch --protect command. --delete Delete the named branch. If there are any patches left in the branch, StGit will refuse to delete it unless you give the --force flag. A protected branch cannot be deleted; it must be unprotected first (see --unprotect above). If you delete the current branch, you are switched to the "master" branch, if it exists. -d DESCRIPTION, --description DESCRIPTION Set the branch description. --force Force a delete when the series is not empty. STGIT
Part of the StGit suite - see linkman:stg[1] StGit 03/13/2012 STG-BRANCH(1)
All times are GMT -4. The time now is 05:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy